summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2017-02-05 17:50:57 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2017-02-05 17:50:57 +0000
commit57cb0b342004378ad4065f07443ab1d835aefaad (patch)
treeb6b53b07875da92c9095d302779f50e4f96b310d /src
parentFix styling breakage from r15471. (diff)
downloadinkscape-57cb0b342004378ad4065f07443ab1d835aefaad.tar.gz
inkscape-57cb0b342004378ad4065f07443ab1d835aefaad.zip
fix crash when inserting nodes
Fixed bugs: - https://launchpad.net/bugs/1617615 (bzr r15479)
Diffstat (limited to 'src')
-rw-r--r--src/ui/tool/multi-path-manipulator.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index c908cede2..4f152e0a2 100644
--- a/src/ui/tool/multi-path-manipulator.h
+++ b/src/ui/tool/multi-path-manipulator.h
@@ -82,8 +82,19 @@ private:
template <typename R>
void invokeForAll(R (PathManipulator::*method)()) {
- for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
- ((i->second.get())->*method)();
+ for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ) {
+ // Sometimes the PathManipulator got freed at loop end, thus
+ // invalidating the iterator so make sure that next_i will
+ // be a valid iterator and then assign i to it.
+ MapType::iterator next_i = i;
+ ++next_i;
+ // i->second is a boost::shared_ptr so try to hold on to it so
+ // it won't get freed prematurely by the WriteXML() method or
+ // whatever. See https://bugs.launchpad.net/inkscape/+bug/1617615
+ // Applicable to empty paths.
+ boost::shared_ptr<PathManipulator> hold(i->second);
+ ((hold.get())->*method)();
+ i = next_i;
}
}
template <typename R, typename A>