Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not deactivate / activate mapTool when it is already active
  • Loading branch information
YoannQDQ authored and nyalldawson committed Apr 24, 2023
1 parent 7997331 commit a61463a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/gui/auto_generated/qgsmaptool.sip.in
Expand Up @@ -178,6 +178,15 @@ called when set as currently active map tool
virtual void deactivate();
%Docstring
called when map tool is being deactivated
%End

virtual void reactivate();
%Docstring
Called when the map tool is being activated while it is already active.

The default implementation does nothing.

.. versionadded:: 3.32
%End

virtual void clean();
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -2713,6 +2713,12 @@ void QgsMapCanvas::setMapTool( QgsMapTool *tool, bool clean )
if ( !tool )
return;

if ( tool == mMapTool )
{
mMapTool->reactivate();
return;
}

if ( mMapTool )
{
if ( clean )
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsmaptool.cpp
Expand Up @@ -117,6 +117,12 @@ void QgsMapTool::deactivate()
emit deactivated();
}


void QgsMapTool::reactivate()
{

}

void QgsMapTool::clean()
{

Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgsmaptool.h
Expand Up @@ -192,6 +192,14 @@ class GUI_EXPORT QgsMapTool : public QObject
//! called when map tool is being deactivated
virtual void deactivate();

/**
* Called when the map tool is being activated while it is already active.
*
* The default implementation does nothing.
* \since QGIS 3.32
*/
virtual void reactivate();

//! convenient method to clean members
virtual void clean();

Expand Down

0 comments on commit a61463a

Please sign in to comment.