Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix crash in QgsMapToolCapture destructor if tool is deleted as a res…
…ult of parent canvas deletion
- Loading branch information
Showing
with
11 additions
and
3 deletions.
-
+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 |
|
|