[Qgis-developer] segmentation fault in plugin using zoom tool

Tim Sutton tim at linfiniti.com
Thu Oct 5 11:05:44 EDT 2006


Hi

On 10/5/06, Martin Dobias <wonder.sk at gmail.com> wrote:
> On 10/5/06, Tim Sutton <tim at linfiniti.com> wrote:
> > > if I recall correctly, you shouldn't store map tool because the tool
> > > is owned by map canvas and the old tool gets always deleted in
> > > QgsMapCanvas::setMapTool.
> >
> > Oh? So my tutorial is wrong?
> >
> > http://blog.qgis.org/?q=node/14
> >
> > I created the tools in the ctor and store them as class members. My
> > tutorial app works - is this just because by luck the memory used by
> > the pointer hasnt been overwritten? I thought delete will clear the
> > memory used too?
>
> Hi Tim,
>
> now I took another look on your tutorial and the map canvas sources
> and - yes, that tutorial doesn't fit exactly into my original thoughts
> of how should it work. Why does it work? I've found out that it's
> because of a bug in QgsMapCanvas::setMapTool that prevents deletion of
> old tool when changing from zoom tool to another zoom tool (since also
> tool for panning is considered as zoom tool). This also means that a
> memory leak is happening in QGIS when switching between memory tools.
>
> So, the question is - how to solve this. I would say that the way how
> you use map tools in the tutorial is more straightforward. I guess the
> best way is to modify the setMapTool function (and some others calling
> it) not to take ownership and not to delete the map tools. I'll
> investigate it and will alter that if I won't find any great problems.
> This will result in policy that caller will create the map tool and
> will have to delete it afterwards - and the tutorial can be left
> unmodified :-)
>
> What do you think about that?
>

Sounds good!

Regards

Tim

> Martin
>


-- 
-- 
Tim Sutton

Visit http://qgis.org for a great Open Source GIS
Home Page: http://linfiniti.com
Skype: timlinux
MSN: tim_bdworld at msn.com
Yahoo: tim_bdworld at yahoo.com
Jabber: timlinux
Irc: timlinux on #qgis at freenode.net



More information about the Qgis-developer mailing list