Skip to content
Permalink
Browse files

add guard for mesh layer data provider and test

  • Loading branch information
vcloarec authored and nyalldawson committed May 17, 2020
1 parent 2338b14 commit 8a4f7731981ff0bb2b5e8198f012786cb284581b
@@ -394,7 +394,7 @@ int QgsMeshDataset3dGeometry::extractDataset( QVector<double> &verticalMagnitude
{
QgsMeshLayer *layer = meshLayer();

if ( !layer )
if ( !layer || !layer->dataProvider() )
return 0;

QgsMeshDatasetIndex scalarDatasetIndex = layer->activeScalarDatasetAtTime( mTimeRange );
@@ -316,7 +316,7 @@ void QgsMesh3dMaterial::configure()

void QgsMesh3dMaterial::configureArrows( QgsMeshLayer *layer, const QgsDateTimeRange &timeRange )
{
if ( !layer )
if ( !layer || !layer->dataProvider() )
return;

QgsMeshDatasetIndex datasetIndex = layer->activeVectorDatasetAtTime( timeRange );
@@ -428,6 +428,8 @@ void QgsMeshLayerProperties::aboutToShowStyleMenu()

void QgsMeshLayerProperties::reloadTemporalProperties()
{
if ( !mMeshLayer->dataProvider() )
return;
QgsMeshDataProviderTemporalCapabilities *temporalCapabalities = mMeshLayer->dataProvider()->temporalCapabilities();
QgsDateTimeRange timeExtent;
QDateTime referenceTime = temporalCapabalities->referenceTime();
@@ -446,6 +448,8 @@ void QgsMeshLayerProperties::reloadTemporalProperties()

void QgsMeshLayerProperties::onTimeReferenceChange()
{
if ( !mMeshLayer->dataProvider() )
return;
const QgsDateTimeRange &timeExtent = mMeshLayer->dataProvider()->temporalCapabilities()->timeExtent( mTemporalDateTimeReference->dateTime() );
mTemporalDateTimeStart->setDateTime( timeExtent.begin() );
mTemporalDateTimeEnd->setDateTime( timeExtent.end() );
@@ -61,14 +61,16 @@ void QgsMeshStaticDatasetWidget::setScalarDatasetGroup( int index )
{
mScalarDatasetGroup = index;
mDatasetScalarModel->setDatasetGroup( index );
mScalarName->setText( mLayer->dataProvider()->datasetGroupMetadata( index ).name() );
if ( mLayer && mLayer->dataProvider() )
mScalarName->setText( mLayer->dataProvider()->datasetGroupMetadata( index ).name() );
}

void QgsMeshStaticDatasetWidget::setVectorDatasetGroup( int index )
{
mVectorDatasetGroup = index;
mDatasetVectorModel->setDatasetGroup( index );
mVectorName->setText( mLayer->dataProvider()->datasetGroupMetadata( index ).name() );
if ( mLayer && mLayer->dataProvider() )
mVectorName->setText( mLayer->dataProvider()->datasetGroupMetadata( index ).name() );
}

QgsMeshDatasetListModel::QgsMeshDatasetListModel( QObject *parent ): QAbstractListModel( parent )
@@ -174,7 +174,8 @@ void QgsRendererMeshPropertiesWidget::onActiveScalarGroupChanged( int groupIndex

void QgsRendererMeshPropertiesWidget::onActiveVectorGroupChanged( int groupIndex )
{
if ( groupIndex >= 0 && !mMeshLayer->dataProvider()->datasetGroupMetadata( groupIndex ).isVector() )
if ( !mMeshLayer->dataProvider() ||
( groupIndex >= 0 && !mMeshLayer->dataProvider()->datasetGroupMetadata( groupIndex ).isVector() ) )
groupIndex = -1;
mMeshRendererVectorSettingsWidget->setActiveDatasetGroup( groupIndex );
mMeshRendererVectorSettingsWidget->syncToLayer();
@@ -41,6 +41,7 @@ class TestQgsMeshLayerPropertiesDialog : public QObject
void init() {} // will be called before each testfunction is executed.
void cleanup() {} // will be called after every testfunction.

void testInvalidLayer();
void testCrs();
void testDatasetGroupTree();

@@ -74,6 +75,15 @@ void TestQgsMeshLayerPropertiesDialog::cleanupTestCase()
QgsApplication::exitQgis();
}

void TestQgsMeshLayerPropertiesDialog::testInvalidLayer()
{
QgsMeshLayer invalidLayer;
std::unique_ptr< QgsMeshLayerProperties > dialog = qgis::make_unique< QgsMeshLayerProperties> ( &invalidLayer,
mQgisApp->mapCanvas() );

QVERIFY( dialog );
}

void TestQgsMeshLayerPropertiesDialog::testCrs()
{
std::unique_ptr< QgsMeshLayerProperties > dialog = qgis::make_unique< QgsMeshLayerProperties> ( mpMeshLayer,

0 comments on commit 8a4f773

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