summaryrefslogtreecommitdiffstats
path: root/src/sp-mesh-array.cpp
diff options
context:
space:
mode:
authorStefano Facchini <stefano.facchini@gmail.com>2017-10-25 11:56:42 +0000
committerStefano Facchini <stefano.facchini@gmail.com>2017-11-13 09:28:49 +0000
commit93d72cb93dab69306a4dcb525e09e8524798639f (patch)
treed24cff89b688b762cfc04ca811533b672da079ab /src/sp-mesh-array.cpp
parentUnset the current tool early on shutdown. (diff)
downloadinkscape-93d72cb93dab69306a4dcb525e09e8524798639f.tar.gz
inkscape-93d72cb93dab69306a4dcb525e09e8524798639f.zip
SPMeshArray: fix a crash when dragging control points
It used to work with the old GSList code because objects where prepended instead of appended, so they were freed in the "right" order. But actually it's enough to delete the row objects, the children are then automatically deleted.
Diffstat (limited to 'src/sp-mesh-array.cpp')
-rw-r--r--src/sp-mesh-array.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp
index a8d9e589c..905ad97eb 100644
--- a/src/sp-mesh-array.cpp
+++ b/src/sp-mesh-array.cpp
@@ -935,27 +935,18 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) {
mg_array = mg;
}
- // First we must delete reprs for old mesh rows and patches.
- std::vector<SPObject*> descendant_objects;
- std::vector<Inkscape::XML::Node *> descendant_reprs;
- for (auto& row: mg_array->children) {
- descendant_reprs.push_back(row.getRepr());
- descendant_objects.push_back(&row);
- for (auto& patch: row.children) {
- descendant_reprs.push_back(patch.getRepr());
- descendant_objects.push_back(&patch);
- for (auto& stop: patch.children) {
- descendant_reprs.push_back(stop.getRepr());
- descendant_objects.push_back(&stop);
- }
- }
+ // First we must delete reprs for old mesh rows and patches. We only need to call the
+ // deleteObject() method, which in turn calls sp_repr_unparent. Since iterators do not play
+ // well with boost::intrusive::list (which ChildrenList derive from) we need to iterate over a
+ // copy of the pointers to the objects.
+ std::vector<SPObject*> children_pointers;
+ for (auto& row : mg_array->children) {
+ children_pointers.push_back(&row);
}
- for (auto i:descendant_objects)
+ for (auto i : children_pointers) {
i->deleteObject();
-
- for (auto i:descendant_reprs)
- sp_repr_unparent(i);
+ }
// Now we build new reprs
Inkscape::XML::Node *mesh = mg->getRepr();