Skip to content

Commit

Permalink
Gui: [skip ci] when closing document via context-menu ask the user fi…
Browse files Browse the repository at this point in the history
…rst how to continue

See also forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=51746
  • Loading branch information
wwmayer committed Nov 3, 2020
1 parent 709c0b5 commit 0324d2d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Gui/Tree.cpp
Expand Up @@ -2209,13 +2209,16 @@ void TreeWidget::onReloadDoc() {
}
}

void TreeWidget::onCloseDoc() {
void TreeWidget::onCloseDoc()
{
if (!this->contextItem || this->contextItem->type() != DocumentType)
return;
DocumentItem* docitem = static_cast<DocumentItem*>(this->contextItem);
App::Document* doc = docitem->document()->getDocument();
try {
Command::doCommand(Command::Doc, "App.closeDocument(\"%s\")", doc->getName());
DocumentItem* docitem = static_cast<DocumentItem*>(this->contextItem);
Gui::Document* gui = docitem->document();
App::Document* doc = gui->getDocument();
if (gui->canClose(true, true))
Command::doCommand(Command::Doc, "App.closeDocument(\"%s\")", doc->getName());
} catch (const Base::Exception& e) {
e.ReportException();
} catch (std::exception &e) {
Expand Down

0 comments on commit 0324d2d

Please sign in to comment.