diff --git a/libs/flake/KoShapeContainer.cpp b/libs/flake/KoShapeContainer.cpp index 411098c702d909ebb0c3406bc8f82f19ae70623c..5f9ec1a7795572f7ffe7cd2531002fd93321b7ff 100644 --- a/libs/flake/KoShapeContainer.cpp +++ b/libs/flake/KoShapeContainer.cpp @@ -30,6 +30,7 @@ #include #include "kis_painting_tweaks.h" +#include "kis_assert.h" KoShapeContainerPrivate::KoShapeContainerPrivate(KoShapeContainer *q) : KoShapePrivate(q), @@ -58,9 +59,14 @@ KoShapeContainer::~KoShapeContainer() { Q_D(KoShapeContainer); if (d->model) { - Q_FOREACH (KoShape *shape, d->model->shapes()) { + QList ownedShapes = d->model->shapes(); + + Q_FOREACH (KoShape *shape, ownedShapes) { + shape->setParent(0); delete shape; } + + KIS_SAFE_ASSERT_RECOVER_NOOP(!d->model->count()); } } diff --git a/libs/flake/tests/TestSvgParser.cpp b/libs/flake/tests/TestSvgParser.cpp index c5199faae4555b39b9d99db10f22c59b0c267bb8..8e01f9ad8b8ccb2da47b2d3d1d138e255863c3c2 100644 --- a/libs/flake/tests/TestSvgParser.cpp +++ b/libs/flake/tests/TestSvgParser.cpp @@ -47,6 +47,11 @@ struct SvgTester } + ~SvgTester () + { + qDeleteAll(shapes); + } + void run() { shapes = parser.parseSvg(root, &fragmentSize); }