Skip to content

Commit d4b276a

Browse files
PeterPetriknyalldawson
authored andcommittedJun 3, 2019
fix #30028 Closing Vertex Edititor crashes the app
1 parent b31f516 commit d4b276a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed
 

‎src/app/vertextool/qgsvertextool.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ QgsVertexTool::~QgsVertexTool()
313313
delete mVertexBand;
314314
delete mEdgeBand;
315315
delete mEndpointMarker;
316+
delete mVertexEditor;
316317
}
317318

318319
void QgsVertexTool::activate()
@@ -1391,12 +1392,12 @@ void QgsVertexTool::showVertexEditor() //#spellok
13911392
{
13921393
if ( !mVertexEditor )
13931394
{
1394-
mVertexEditor.reset( new QgsVertexEditor( mCanvas ) );
1395-
if ( !QgisApp::instance()->restoreDockWidget( mVertexEditor.get() ) )
1396-
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mVertexEditor.get() );
1395+
mVertexEditor = new QgsVertexEditor( mCanvas );
1396+
if ( !QgisApp::instance()->restoreDockWidget( mVertexEditor ) )
1397+
QgisApp::instance()->addDockWidget( Qt::LeftDockWidgetArea, mVertexEditor );
13971398

1398-
connect( mVertexEditor.get(), &QgsVertexEditor::deleteSelectedRequested, this, &QgsVertexTool::deleteVertexEditorSelection );
1399-
connect( mVertexEditor.get(), &QgsVertexEditor::editorClosed, this, &QgsVertexTool::cleanupVertexEditor );
1399+
connect( mVertexEditor, &QgsVertexEditor::deleteSelectedRequested, this, &QgsVertexTool::deleteVertexEditorSelection );
1400+
connect( mVertexEditor, &QgsVertexEditor::editorClosed, this, &QgsVertexTool::cleanupVertexEditor );
14001401

14011402
// timer required as showing/raising the vertex editor in the same function following restoreDockWidget fails
14021403
QTimer::singleShot( 200, this, [ = ] { mVertexEditor->show(); mVertexEditor->raise(); } );
@@ -1411,7 +1412,10 @@ void QgsVertexTool::showVertexEditor() //#spellok
14111412
void QgsVertexTool::cleanupVertexEditor()
14121413
{
14131414
mLockedFeature.reset();
1414-
mVertexEditor.reset();
1415+
// do not delete immediately because vertex editor
1416+
// can be still used in the qt event loop
1417+
mVertexEditor->deleteLater();
1418+
14151419
updateLockedFeatureVertices();
14161420
}
14171421

‎src/app/vertextool/qgsvertextool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <memory>
2020

21+
#include <QPointer>
22+
2123
#include "qgis_app.h"
2224
#include "qgsmaptooladvanceddigitizing.h"
2325
#include "qgsgeometry.h"
@@ -447,7 +449,7 @@ class APP_EXPORT QgsVertexTool : public QgsMapToolAdvancedDigitizing
447449
//! Locked feature for the vertex editor
448450
std::unique_ptr<QgsLockedFeature> mLockedFeature;
449451
//! Dock widget which allows editing vertices
450-
std::unique_ptr<QgsVertexEditor> mVertexEditor;
452+
QPointer<QgsVertexEditor> mVertexEditor;
451453

452454
/**
453455
* Data structure that stores alternative features to the currently selected (locked) feature.

0 commit comments

Comments
 (0)
Please sign in to comment.