From d48846b153374196a5cddae842e06ba2ff98d12a Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 29 Jan 2015 17:36:35 +0300 Subject: [PATCH] Fix for issue #136 : set null active document when all documents are closing --- src/Model/Model_Document.cpp | 3 +++ src/Model/Model_Session.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 680b7fd3e..2499f0366 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -242,6 +242,9 @@ void Model_Document::close(const bool theForever) std::shared_ptr aPM = Model_Session::get(); if (this != aPM->moduleDocument().get() && this == aPM->activeDocument().get()) { aPM->setActiveDocument(aPM->moduleDocument()); + } else if (this == aPM->moduleDocument().get()) { + // erase the active document if root is closed + aPM->setActiveDocument(DocumentPtr()); } // close all subs const std::set aSubs = subDocuments(true); diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 9f1783fe7..816b87f75 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -187,10 +187,10 @@ void Model_Session::setActiveDocument( { if (myCurrentDoc != theDoc) { myCurrentDoc = theDoc; - if (theSendSignal) { + if (theDoc.get() && theSendSignal) { // syncronize the document: it may be just opened or opened but removed before std::shared_ptr aDoc = std::dynamic_pointer_cast(theDoc); - if (aDoc) { + if (aDoc.get()) { bool aWasChecked = myCheckTransactions; setCheckTransactions(false); aDoc->synchronizeFeatures(false, true); -- 2.39.2