Avoid crash when disconnecting layer

This commit is contained in:
Matthias Kuhn 2018-10-16 10:12:30 +02:00
parent 8da2910993
commit 6c97fcf80f
No known key found for this signature in database
GPG Key ID: 7A7F1A1C90C3E6A7
2 changed files with 9 additions and 0 deletions

View File

@ -265,6 +265,7 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
{
disconnect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
}
mCurrentLayer = qobject_cast<QgsVectorLayer *>( layer );
@ -273,6 +274,7 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
{
connect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
}
onLayerEditingStatusChanged();
@ -297,6 +299,12 @@ void QgsGeometryValidationDock::onLayerEditingStatusChanged()
mTopologyChecksPendingButton->setEnabled( enabled );
}
void QgsGeometryValidationDock::onLayerDestroyed( QObject *layer )
{
if ( layer == mCurrentLayer )
mCurrentLayer = nullptr;
}
void QgsGeometryValidationDock::showHighlight( const QModelIndex &current )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );

View File

@ -48,6 +48,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
void onCurrentErrorChanged( const QModelIndex &current, const QModelIndex &previous );
void onCurrentLayerChanged( QgsMapLayer *layer );
void onLayerEditingStatusChanged();
void onLayerDestroyed( QObject *layer );
void gotoNextError();
void gotoPreviousError();
void zoomToProblem();