BIM: close task panels on doc close

Fixes #17952.

This PR is a continuation of #20719.

It mainly involves adding `self.doc`. This new attribute is then also used in the rest of the modified classes. In some cases code was slightly reordered for consistency.

The `_finish_command_on_doc_close` function has been modifief to also handle `Gui.Snapper.ui.escape` and the code in gui_arcs.py has been updated accordingly.

Additionally:
Removed the `done` and `spacedone` variables in BimWall.py by tweaking the code.
This commit is contained in:
Roy-043
2025-04-30 10:17:13 +02:00
committed by Yorik van Havre
parent 8340737e86
commit 24e15ecb61
12 changed files with 138 additions and 106 deletions

View File

@@ -1,3 +1,27 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2025 FreeCAD Project Association *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
import FreeCAD as App
if App.GuiUp:
@@ -34,9 +58,13 @@ if App.GuiUp:
and use a task panel.
"""
if getattr(App, "activeDraftCommand", None) \
and getattr(App.activeDraftCommand, "doc", None) == gui_doc.Document \
and getattr(App.activeDraftCommand, "ui", None):
if hasattr(App.activeDraftCommand.ui, "reject"):
ToDo.delay(App.activeDraftCommand.ui.reject, None)
elif hasattr(App.activeDraftCommand.ui, "escape"):
ToDo.delay(App.activeDraftCommand.ui.escape, None)
and getattr(App.activeDraftCommand, "doc", None) == gui_doc.Document:
if hasattr(App.activeDraftCommand, "ui"):
if hasattr(App.activeDraftCommand.ui, "reject"):
ToDo.delay(App.activeDraftCommand.ui.reject, None)
elif hasattr(App.activeDraftCommand.ui, "escape"):
ToDo.delay(App.activeDraftCommand.ui.escape, None)
elif hasattr(Gui, "Snapper") \
and hasattr(Gui.Snapper, "ui") \
and hasattr(Gui.Snapper.ui, "escape"):
ToDo.delay(Gui.Snapper.ui.escape, None)