Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 0550d43
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0550d43

Please sign in to comment.