Skip to content
Permalink
Browse files

Avoid crash when disconnecting layer

  • Loading branch information
m-kuhn committed Oct 16, 2018
1 parent 8da2910 commit 6c97fcf80f6d10780dfc634e533e9a33b24ad906
Showing with 9 additions and 0 deletions.
  1. +8 −0 src/app/qgsgeometryvalidationdock.cpp
  2. +1 −0 src/app/qgsgeometryvalidationdock.h
@@ -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() );
@@ -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();

0 comments on commit 6c97fcf

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