Skip to content

Commit

Permalink
fix crash when the current maptool is destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 14, 2012
1 parent 659abb8 commit 076e6ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1170,7 +1170,10 @@ void QgsMapCanvas::setMapTool( QgsMapTool* tool )
return;

if ( mMapTool )
{
disconnect( mMapTool, SIGNAL( destroyed() ), this, SLOT( mapToolDestroyed() ) );
mMapTool->deactivate();
}

if ( tool->isTransient() && mMapTool && !mMapTool->isTransient() )
{
Expand All @@ -1187,7 +1190,10 @@ void QgsMapCanvas::setMapTool( QgsMapTool* tool )
// set new map tool and activate it
mMapTool = tool;
if ( mMapTool )
{
connect( mMapTool, SIGNAL( destroyed() ), this, SLOT( mapToolDestroyed() ) );
mMapTool->activate();
}

emit mapToolSet( mMapTool );
} // setMapTool
Expand Down Expand Up @@ -1548,3 +1554,9 @@ void QgsMapCanvas::crsTransformEnabled( bool enabled )
else
disconnect( mMapRenderer, SIGNAL( destinationSrsChanged() ), this, SLOT( refresh() ) );
}

void QgsMapCanvas::mapToolDestroyed()
{
QgsDebugMsg( "maptool destroyed" );
mMapTool = 0;
}
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -301,6 +301,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! called to write map canvas settings to project
void writeProject( QDomDocument & );

private slots:
//! called when current maptool is destroyed
void mapToolDestroyed();

signals:
/** Let the owner know how far we are with render operations */
void setProgress( int, int );
Expand Down

0 comments on commit 076e6ff

Please sign in to comment.