Skip to content
Permalink
Browse files
fix crash when the current maptool is destroyed
  • Loading branch information
jef-n committed Feb 14, 2012
1 parent 659abb8 commit 076e6ff7ba9f58d008ba6e73d7d829858ec219ab
Showing with 16 additions and 0 deletions.
  1. +12 −0 src/gui/qgsmapcanvas.cpp
  2. +4 −0 src/gui/qgsmapcanvas.h
@@ -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() )
{
@@ -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
@@ -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;
}
@@ -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 );

0 comments on commit 076e6ff

Please sign in to comment.