Skip to content

Commit

Permalink
Avoid crash when disconnecting layer
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 16, 2018
1 parent 8da2910 commit 6c97fcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -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 );
Expand All @@ -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();
Expand All @@ -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() );
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsgeometryvalidationdock.h
Expand Up @@ -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();
Expand Down

0 comments on commit 6c97fcf

Please sign in to comment.