diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 2afa28943380..854f56a8da0b 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1468,10 +1468,13 @@ void Document::restore (void) // clean up if the document is not empty // !TODO mind exeptions while restoring! clearUndos(); + // first notify the objects to being deleted and then delete them in a second loop (#0002521) + // FIXME: To delete every object individually is inefficient. Add a new signal 'signalClear' + // and then clear everything in one go. for (std::vector::iterator obj = d->objectArray.begin(); obj != d->objectArray.end(); ++obj) { - // NOTE don't call unsetupObject () here due to it is intended to do some manipulations - // on other objects, but here we are wiping out document completely signalDeletedObject(*(*obj)); + } + for (std::vector::iterator obj = d->objectArray.begin(); obj != d->objectArray.end(); ++obj) { delete *obj; } d->objectArray.clear();