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

nitin quick quick.nitin at gmail.com
Thu Oct 5 05:07:11 EDT 2006


thanks martin , it did help and solved my issue.

segmentation fault was happening at qgsmapcanvas.cpp :818
818:            if(tool && too->isZoomTool())

 but i still have some doubt. This issue is arising with tools
available at ATTRIBUTE TOOLBAR. There are no issue with the ones
available at navigation tool bar but we use same code for both.

thanks one again
regards
quickNitin.

On 10/5/06, Martin Dobias <wonder.sk at gmail.com> wrote:
> On 10/5/06, nitin quick <quick.nitin at gmail.com> wrote:
> > greetings developers,
> > i am currently coding a plugin which will make use of map tools but it
> > is giving me seg fault.
> > Operation is such : plugin has a pointer to qgsmaptoolzoom, on
> > activating action for this plugin it do
> >
> > PointTool::PointTool(QgisApp * theQGisApp,
> >                                        QgisIface * theQgisInterface):
> >                  QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
> >                  mQGisApp(theQGisApp),
> >                  mQGisIface(theQgisInterface)
> > {
> >         zoomTool=new QgsMapToolZoom(mQGisIface->getMapCanvas(),false);
> > }
> >
> > void PointTool::okReceived()
> > {
> >         mQGisIface->getMapCanvas()->setMapTool(zoomTool);
> >
> > }
> > this will make zoomTool current map tool.
> > Aftert this if i select tool identifyfeature, and again select
> > zoomTool from plugin menu it results in segmentation fault. I couldn't
> > find solution for this problem. please help me get out of it. The code
> > which i put up is i think only relevant here, rest is std generated by
> > plugin builder or i can put whole code.
> > quickNitin
>
> Hi,
>
> 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. So your code should look like
>
> void PointTool::okReceived()
> {
>         QgsMapCanvas* canvas = mQGisIface->getMapCanvas();
>         canvas->setMapTool(new QgsMapToolZoom(canvas,false));
> }
>
> Hope that helps,
> Martin
>



More information about the Qgis-developer mailing list