[Merkaartor] SEGV when opening geotagged images

Toby Speight T.M.Speight.90 at cantab.net
Mon May 4 12:29:42 BST 2009


I frequently get a segmentation fault when loading JPEG images.  I
traced it down to this code:

/--------
| 		if (positionValid) {
| 			Coord newPos(angToInt(lat), angToInt(lon));
| 			TrackPoint *Pt;
|             QList<MapFeature*>::ConstIterator it = theLayer->get().constBegin();
|             QList<MapFeature*>::ConstIterator end = theLayer->get().constEnd();
| 			for (; it != end; it++) // use existing TrackPoint if there is one in small distance 
| 				if ((Pt = qobject_cast<TrackPoint*>(*it)) &&
| 				 Pt->position().distanceFrom(newPos) <= .002)
| 					break;
| 			if (it == end)
| 				Pt = new TrackPoint(newPos);
| 
| 			Pt->setTag("Picture", "GeoTagged");
| 			usedTrackPoints << TrackPointData(Pt->id(), file, time, it == end);
| 			//if (it == end)
| 				theLayer->add(Pt);
| 				//new AddFeatureCommand(theLayer, Pt, false);
\--------

Looking at the backtrace in gdb, it seems that the
"qobject_cast<TrackPoint*>" sometimes fails, which I think means that
*it isn't a valid QObject.  But I don't know how to investigate further.

For now, my workaround is to disable the iteration, and always create
new points, and that seems to make Merkaartor reliable again for me.




More information about the Merkaartor mailing list