Skip to content

Commit 076e6ff

Browse files
committed
fix crash when the current maptool is destroyed
1 parent 659abb8 commit 076e6ff

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/gui/qgsmapcanvas.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,10 @@ void QgsMapCanvas::setMapTool( QgsMapTool* tool )
11701170
return;
11711171

11721172
if ( mMapTool )
1173+
{
1174+
disconnect( mMapTool, SIGNAL( destroyed() ), this, SLOT( mapToolDestroyed() ) );
11731175
mMapTool->deactivate();
1176+
}
11741177

11751178
if ( tool->isTransient() && mMapTool && !mMapTool->isTransient() )
11761179
{
@@ -1187,7 +1190,10 @@ void QgsMapCanvas::setMapTool( QgsMapTool* tool )
11871190
// set new map tool and activate it
11881191
mMapTool = tool;
11891192
if ( mMapTool )
1193+
{
1194+
connect( mMapTool, SIGNAL( destroyed() ), this, SLOT( mapToolDestroyed() ) );
11901195
mMapTool->activate();
1196+
}
11911197

11921198
emit mapToolSet( mMapTool );
11931199
} // setMapTool
@@ -1548,3 +1554,9 @@ void QgsMapCanvas::crsTransformEnabled( bool enabled )
15481554
else
15491555
disconnect( mMapRenderer, SIGNAL( destinationSrsChanged() ), this, SLOT( refresh() ) );
15501556
}
1557+
1558+
void QgsMapCanvas::mapToolDestroyed()
1559+
{
1560+
QgsDebugMsg( "maptool destroyed" );
1561+
mMapTool = 0;
1562+
}

src/gui/qgsmapcanvas.h

+4
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
301301
//! called to write map canvas settings to project
302302
void writeProject( QDomDocument & );
303303

304+
private slots:
305+
//! called when current maptool is destroyed
306+
void mapToolDestroyed();
307+
304308
signals:
305309
/** Let the owner know how far we are with render operations */
306310
void setProgress( int, int );

0 commit comments

Comments
 (0)