Skip to content

Commit 56b6ebd

Browse files
committedAug 17, 2018
Avoid crash from storage of potentially removed map layer storage in canvas
1 parent 8075368 commit 56b6ebd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎src/gui/qgsmapcanvas.cpp‎

Lines changed: 3 additions & 0 deletions
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
928928
bool mRenderFlag = true;
929929

930930
//! current layer in legend
931-
QgsMapLayer *mCurrentLayer = nullptr;
931+
QPointer< QgsMapLayer > mCurrentLayer;
932932

933933
//! graphics scene manages canvas items
934934
QGraphicsScene *mScene = nullptr;

0 commit comments

Comments
 (0)
Please sign in to comment.