Skip to content

Commit cddbf96

Browse files
committed
Avoid crash from storage of potentially removed map layer storage in canvas
(cherry-picked from 56b6ebd)
1 parent 6fd5b23 commit cddbf96

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/gui/qgsmapcanvas.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ QgsMapLayer *QgsMapCanvas::layer( int index )
285285

286286
void QgsMapCanvas::setCurrentLayer( QgsMapLayer *layer )
287287
{
288+
if ( mCurrentLayer == layer )
289+
return;
290+
288291
mCurrentLayer = layer;
289292
emit currentLayerChanged( layer );
290293
}

src/gui/qgsmapcanvas.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
917917
bool mRenderFlag = true;
918918

919919
//! current layer in legend
920-
QgsMapLayer *mCurrentLayer = nullptr;
920+
QPointer< QgsMapLayer > mCurrentLayer;
921921

922922
//! graphics scene manages canvas items
923923
QGraphicsScene *mScene = nullptr;

0 commit comments

Comments
 (0)