Skip to content
Permalink
Browse files

Fix crash in QgsMapToolCapture destructor if tool is deleted as a res…

…ult of parent canvas deletion
  • Loading branch information
nyalldawson committed Feb 8, 2021
1 parent bc52304 commit 0550d435a2265f59b01f31ffea818ddd477f2c9f
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/gui/qgsmaptoolcapture.cpp
@@ -71,16 +71,21 @@ QgsMapToolCapture::QgsMapToolCapture( QgsMapCanvas *canvas, QgsAdvancedDigitizin

QgsMapToolCapture::~QgsMapToolCapture()
{
// during tear down we have to clean up mExtraSnapLayer first, before
// we call stop capturing. Otherwise stopCapturing tries to access members
// from the mapcanvas, which is likely already being destroyed and triggering
// the deletion of this object...
mCanvas->snappingUtils()->removeExtraSnapLayer( mExtraSnapLayer );
mExtraSnapLayer->deleteLater();
mExtraSnapLayer = nullptr;

stopCapturing();

if ( mValidator )
{
mValidator->deleteLater();
mValidator = nullptr;
}
mCanvas->snappingUtils()->removeExtraSnapLayer( mExtraSnapLayer );
mExtraSnapLayer->deleteLater();
mExtraSnapLayer = nullptr;
}

QgsMapToolCapture::Capabilities QgsMapToolCapture::capabilities() const
@@ -987,6 +992,9 @@ QgsPoint QgsMapToolCapture::mapPoint( const QgsMapMouseEvent &e ) const

void QgsMapToolCapture::updateExtraSnapLayer()
{
if ( !mExtraSnapLayer )
return;

if ( canvas()->snappingUtils()->config().selfSnapping() && mCanvas->currentLayer() && mCaptureCurve.numPoints() >= 2 )
{
// the current layer may have changed

0 comments on commit 0550d43

Please sign in to comment.