From 0324d2de6471231f101860f5aad8724db86a4160 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 3 Nov 2020 12:09:28 +0100 Subject: [PATCH] Gui: [skip ci] when closing document via context-menu ask the user first how to continue See also forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=51746 --- src/Gui/Tree.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 8bafbdfc07..457ee84d10 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -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(this->contextItem); - App::Document* doc = docitem->document()->getDocument(); try { - Command::doCommand(Command::Doc, "App.closeDocument(\"%s\")", doc->getName()); + DocumentItem* docitem = static_cast(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) {