Skip to content
Permalink
Browse files

fix crash if MDAL not available

  • Loading branch information
vcloarec authored and nyalldawson committed Sep 18, 2020
1 parent 4113fdc commit 083cb88c605cf445a6bac1d348f2cbdb2a65922c
@@ -58,8 +58,11 @@ void QgsTinMeshCreationAlgorithm::initAlgorithm( const QVariantMap &configuratio
Q_UNUSED( configuration );
addParameter( new QgsProcessingParameterTinInputLayers( QStringLiteral( "SOURCE_DATA" ), QObject::tr( "Input layers" ) ) );

const QList<QgsMeshDriverMetadata> &driverList =
QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) )->meshDriversMetadata();
QgsProviderMetadata *meta = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) );

QList<QgsMeshDriverMetadata> driverList;
if ( meta )
driverList = meta->meshDriversMetadata();

for ( const QgsMeshDriverMetadata &driverMeta : driverList )
if ( driverMeta.capabilities() & QgsMeshDriverMetadata::CanWriteMeshData )
@@ -180,3 +183,14 @@ void QgsTinMeshCreationAlgorithm::addZValueDataset( const QString &fileName, con
int datasetGroupIndex = tempLayer->datasetGroupCount() - 1;
tempLayer->saveDataset( fileName, datasetGroupIndex, driver );
}

bool QgsTinMeshCreationAlgorithm::canExecute( QString *errorMessage ) const
{
if ( mAvailableFormat.count() == 0 )
{
*errorMessage = QObject::tr( "MDAL not available" );
return false;
}

return true;
}
@@ -34,6 +34,7 @@ class QgsTinMeshCreationAlgorithm: public QgsProcessingAlgorithm
QString shortHelpString() const override;
QString name() const override;
QString displayName() const override;
bool canExecute( QString *errorMessage ) const override;

protected:
QgsProcessingAlgorithm *createInstance() const override;

0 comments on commit 083cb88

Please sign in to comment.
You can’t perform that action at this time.