From f2bad4598ae91e2413980f1113b85d18c1fffeb1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 20 Jun 2016 21:58:00 +0200 Subject: [PATCH] + fix order of removed objects in transaction list + add assert to check for obvious error + removed unneeded method --- src/App/Transactions.cpp | 2 ++ src/Gui/Document.cpp | 12 ++++++------ src/Gui/Document.h | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index afc63ee96..ddf9e6c1b 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -150,6 +150,8 @@ void Transaction::addObjectNew(TransactionalObject *Obj) else { pos->second->status = TransactionObject::New; pos->second->_NameInDocument = Obj->detachFromDocument(); + // move item at the end to make sure the order of removal is kept + _Objects.splice(_Objects.end(), _Objects, pos); } } else { diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index bfbbf6911..de7c6c3a3 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -575,16 +575,16 @@ void Document::slotRedoDocument(const App::Document& doc) void Document::addViewProvider(Gui::ViewProviderDocumentObject* vp) { + // Hint: The undo/redo first adds the view provider to the Gui + // document before adding the objects to the App document. + + // the view provider is added by TransactionViewProvider and an + // object can be there only once + assert(d->_ViewProviderMap.find(vp->getObject()) == d->_ViewProviderMap.end()); vp->setStatus(Detach, false); d->_ViewProviderMap[vp->getObject()] = vp; } -void Document::removeViewProvider(Gui::ViewProviderDocumentObject* vp) -{ - vp->setStatus(Detach, true); - d->_ViewProviderMap.erase(vp->getObject()); -} - void Document::setModified(bool b) { d->_isModified = b; diff --git a/src/Gui/Document.h b/src/Gui/Document.h index 43a216fbb..04b577885 100644 --- a/src/Gui/Document.h +++ b/src/Gui/Document.h @@ -86,7 +86,6 @@ protected: //@} void addViewProvider(Gui::ViewProviderDocumentObject*); - void removeViewProvider(Gui::ViewProviderDocumentObject*); public: /** @name Signals of the document */