Skip to content

Commit

Permalink
in case object deletion fails then make sure to re-enable updates of …
Browse files Browse the repository at this point in the history
…the main window
  • Loading branch information
wwmayer committed Mar 15, 2019
1 parent ca7770b commit 51fcdd2
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/Gui/CommandDoc.cpp
Expand Up @@ -1092,9 +1092,15 @@ void StdCmdDelete::activated(int iMsg)
// handle the view provider
Gui::getMainWindow()->setUpdatesEnabled(false);

(*it)->openTransaction("Delete");
vpedit->onDelete(ft->getSubNames());
(*it)->commitTransaction();
try {
(*it)->openTransaction("Delete");
vpedit->onDelete(ft->getSubNames());
(*it)->commitTransaction();
}
catch (const Base::Exception& e) {
(*it)->abortTransaction();
e.ReportException();
}

Gui::getMainWindow()->setUpdatesEnabled(true);
Gui::getMainWindow()->update();
Expand Down Expand Up @@ -1171,18 +1177,24 @@ void StdCmdDelete::activated(int iMsg)

if (autoDeletion) {
Gui::getMainWindow()->setUpdatesEnabled(false);
(*it)->openTransaction("Delete");
for (std::vector<Gui::SelectionObject>::iterator ft = sel.begin(); ft != sel.end(); ++ft) {
Gui::ViewProvider* vp = pGuiDoc->getViewProvider(ft->getObject());
if (vp) {
// ask the ViewProvider if it wants to do some clean up
if (vp->onDelete(ft->getSubNames())) {
doCommand(Doc,"App.getDocument(\"%s\").removeObject(\"%s\")"
,(*it)->getName(), ft->getFeatName());
try {
(*it)->openTransaction("Delete");
for (std::vector<Gui::SelectionObject>::iterator ft = sel.begin(); ft != sel.end(); ++ft) {
Gui::ViewProvider* vp = pGuiDoc->getViewProvider(ft->getObject());
if (vp) {
// ask the ViewProvider if it wants to do some clean up
if (vp->onDelete(ft->getSubNames())) {
doCommand(Doc,"App.getDocument(\"%s\").removeObject(\"%s\")"
,(*it)->getName(), ft->getFeatName());
}
}
}
(*it)->commitTransaction();
}
catch (const Base::Exception& e) {
(*it)->abortTransaction();
e.ReportException();
}
(*it)->commitTransaction();

Gui::getMainWindow()->setUpdatesEnabled(true);
Gui::getMainWindow()->update();
Expand Down

0 comments on commit 51fcdd2

Please sign in to comment.