Core: Enable TaskDialogs to associate view (#17373)
* Core: Add possibility for task dialogs to associate a view and be able to close when associated view is closed. * TaskImage: Use task dialog view association. * Sketcher: Use task dialog view association. Preventing crash (https://github.com/FreeCAD/FreeCAD/issues/16702) * EditableDatumLabel: Use QPointer to prevent crash
This commit is contained in:
@@ -295,6 +295,9 @@ TaskView::TaskView(QWidget *parent)
|
||||
connectApplicationDeleteDocument =
|
||||
App::GetApplication().signalDeleteDocument.connect
|
||||
(std::bind(&Gui::TaskView::TaskView::slotDeletedDocument, this, sp::_1));
|
||||
connectApplicationClosedView =
|
||||
Gui::Application::Instance->signalCloseView.connect
|
||||
(std::bind(&Gui::TaskView::TaskView::slotViewClosed, this, sp::_1));
|
||||
connectApplicationUndoDocument =
|
||||
App::GetApplication().signalUndoDocument.connect
|
||||
(std::bind(&Gui::TaskView::TaskView::slotUndoDocument, this, sp::_1));
|
||||
@@ -310,6 +313,7 @@ TaskView::~TaskView()
|
||||
{
|
||||
connectApplicationActiveDocument.disconnect();
|
||||
connectApplicationDeleteDocument.disconnect();
|
||||
connectApplicationClosedView.disconnect();
|
||||
connectApplicationUndoDocument.disconnect();
|
||||
connectApplicationRedoDocument.disconnect();
|
||||
Gui::Selection().Detach(this);
|
||||
@@ -479,6 +483,29 @@ void TaskView::slotDeletedDocument(const App::Document& doc)
|
||||
}
|
||||
}
|
||||
|
||||
void TaskView::slotViewClosed(const Gui::MDIView* view)
|
||||
{
|
||||
// It can happen that only a view is closed an not the document
|
||||
if (ActiveDialog) {
|
||||
if (ActiveDialog->isAutoCloseOnClosedView()) {
|
||||
const Gui::MDIView* associatedView = ActiveDialog->getAssociatedView();
|
||||
if (!associatedView) {
|
||||
Base::Console().Warning(std::string("TaskView::slotViewClosed"),
|
||||
"No view associated\n");
|
||||
}
|
||||
|
||||
if (associatedView == view) {
|
||||
ActiveDialog->autoClosedOnClosedView();
|
||||
removeDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ActiveDialog) {
|
||||
updateWatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskView::transactionChangeOnDocument(const App::Document& doc)
|
||||
{
|
||||
if (ActiveDialog) {
|
||||
|
||||
Reference in New Issue
Block a user