Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[vertextool] Fix crash when switching layers with a locked feature pr…
…esent
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Nov 30, 2020
1 parent 3ecbe06 commit 50fd353
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
14 changes: 0 additions & 14 deletions src/app/vertextool/qgslockedfeature.cpp
Expand Up @@ -39,9 +39,6 @@ QgsLockedFeature::QgsLockedFeature( QgsFeatureId featureId,
, mLayer( layer )
, mCanvas( canvas )
{
// signal changing of current layer
connect( QgisApp::instance()->layerTreeView(), &QgsLayerTreeView::currentLayerChanged, this, &QgsLockedFeature::currentLayerChanged );

replaceVertexMap();
}

Expand All @@ -65,12 +62,6 @@ QgsLockedFeature::~QgsLockedFeature()
delete mGeometry;
}

void QgsLockedFeature::currentLayerChanged( QgsMapLayer *layer )
{
if ( layer == mLayer )
deleteLater();
}

void QgsLockedFeature::updateGeometry( const QgsGeometry *geom )
{
delete mGeometry;
Expand Down Expand Up @@ -112,11 +103,6 @@ void QgsLockedFeature::endGeometryChange()
connect( mLayer, &QgsVectorLayer::geometryChanged, this, &QgsLockedFeature::geometryChanged );
}

void QgsLockedFeature::canvasLayersChanged()
{
currentLayerChanged( mCanvas->currentLayer() );
}

void QgsLockedFeature::featureDeleted( QgsFeatureId fid )
{
if ( fid == mFeatureId )
Expand Down
10 changes: 0 additions & 10 deletions src/app/vertextool/qgslockedfeature.h
Expand Up @@ -139,16 +139,6 @@ class QgsLockedFeature: public QObject
*/
void geometryChanged( QgsFeatureId, const QgsGeometry & );

/*
* the current layer changed - destroy
*/
void currentLayerChanged( QgsMapLayer *layer );

/*
* the current layer changed - destroy
*/
void canvasLayersChanged();

/*
* the changes are rolling back - stop monitoring the geometry
*/
Expand Down
15 changes: 15 additions & 0 deletions src/app/vertextool/qgsvertextool.cpp
Expand Up @@ -328,6 +328,8 @@ void QgsVertexTool::activate()
{
showVertexEditor(); //#spellok
}
connect( mCanvas, &QgsMapCanvas::currentLayerChanged, this, &QgsVertexTool::currentLayerChanged );

QgsMapToolAdvancedDigitizing::activate();
}

Expand All @@ -344,9 +346,22 @@ void QgsVertexTool::deactivate()
it->cleanup();
mValidations.clear();

disconnect( mCanvas, &QgsMapCanvas::currentLayerChanged, this, &QgsVertexTool::currentLayerChanged );

QgsMapToolAdvancedDigitizing::deactivate();
}

void QgsVertexTool::currentLayerChanged( QgsMapLayer *layer )
{
if ( mMode == QgsVertexTool::ActiveLayer )
{
if ( mLockedFeature && mLockedFeature->layer() != layer )
{
cleanupLockedFeature();
}
}
}

void QgsVertexTool::addDragBand( const QgsPointXY &v1, const QgsPointXY &v2 )
{
addDragStraightBand( nullptr, v1, v2, false, true, v2 );
Expand Down
2 changes: 2 additions & 0 deletions src/app/vertextool/qgsvertextool.h
Expand Up @@ -124,6 +124,8 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing

void lockedFeatureSelectionChanged();

void currentLayerChanged( QgsMapLayer *layer );

private:

void buildDragBandsForVertices( const QSet<Vertex> &movingVertices, const QgsPointXY &dragVertexMapPoint );
Expand Down

0 comments on commit 50fd353

Please sign in to comment.