[Qgis-developer] API change: map tools

Martin Dobias wonder.sk at gmail.com
Thu Oct 12 20:03:11 EDT 2006


Hi,

according to recent debate on qgis-developer list (in thread
"segmentation fault in plugin using zoom tool"), I've modified the way
how to work with map tools (in revision 5940).

Till now, after setting QgsMapCanvas::setMapTool() map canvas took
ownership of the tool and when it was replaced with another tool, it
got deleted. This showed to be a bit problematic.

New way of using map tools is that caller must save the pointer to the
map tool. When you call setMapTool(), the old tool gets deactivated
and new tool gets activated and set as current. Later, tool has to be
deleted by the owner. There's no problem to delete a tool while it's
being still used as QgsMapTool constructor calls
QgsMapCanvas::unsetMapTool which stops to use that tool if it's active
(or saved as last non-zoom tool).

I hope that it won't introduce any new problems, but if so, let me know.

Martin



More information about the Qgis-developer mailing list