AW: [Qgis-developer] Avoid segmentation fault on selection when commit
Hugentobler Marco
marco.hugentobler at karto.baug.ethz.ch
Tue Jul 15 04:20:51 EDT 2008
Hi Adrien,
You are right, the selection should be adapted when commiting features.
I think it would be difficult to map uncommited ids to commited ids (at least without changing the provider interface). So I'm also in favour of solution 1 and I'm going to apply your patch.
Regards,
Marco
-----Ursprüngliche Nachricht-----
Von: qgis-developer-bounces at lists.osgeo.org im Auftrag von Adrien Gruson
Gesendet: Fr 11.07.2008 16:28
An: qgis-developer at lists.osgeo.org
Betreff: [Qgis-developer] Avoid segmentation fault on selection when commit
Hi all,
I develop Qgis plugin and I have a little problem with selections and
commit.
_
Steps :_
1. You select added features (they have negative id).
2. You commit change (commit attribute positive id to added features)
but your mSelectedFeatureIds haven't updated and have always
negative Id in mSelectedFeatureIds.
3. If the user doesn't reselect features, you have a segmentation
fault because if you do a iteration on mSelectedFeatures there are
wrong id.
_A possible solution :
_
* Erase all negative ids in commitChanges
<http://doc.qgis.org/classQgsVectorLayer.html#fab34baf331320a8c3212993f5fccfa1>
()
Advantage : easy to do
Disadvantage: user's selection change when he commit
* Provider return new id of added feature and replace in
mSelectedFeatureIds.
Advantage : no change for user when he commit.
Disadvantage : more change to do in code.
Ps: I attach patch of first solution.
More information about the Qgis-developer
mailing list