From 319ef46eb72c6c97b361fd7e129f1a1ea5dcce08 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 6 Nov 2014 15:04:52 +0300 Subject: [PATCH] Issue #216: fixed the problem with loading part and activating by double click --- src/Model/Model_Document.cpp | 4 +++- src/Model/Model_Session.cpp | 9 ++++++--- src/Model/Model_Session.h | 3 ++- src/ModelAPI/ModelAPI_Session.h | 3 ++- src/PartSetPlugin/PartSetPlugin_Part.cpp | 10 ---------- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 4ad70e847..8bb7c7809 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -147,8 +147,10 @@ bool Model_Document::load(const char* theFileName) if (!isError) { myDoc->SetUndoLimit(UNDO_LIMIT); // to avoid the problem that feature is created in the current, not this, document - Model_Session::get()->setActiveDocument(anApp->getDocument(myID)); + Model_Session::get()->setActiveDocument(anApp->getDocument(myID), false); synchronizeFeatures(false, true); + Model_Session::get()->setActiveDocument(Model_Session::get()->moduleDocument(), false); + Model_Session::get()->setActiveDocument(anApp->getDocument(myID), true); } return !isError; } diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 13b8a9a50..f78bfb76b 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -144,12 +144,15 @@ boost::shared_ptr Model_Session::activeDocument() return myCurrentDoc; } -void Model_Session::setActiveDocument(boost::shared_ptr theDoc) +void Model_Session::setActiveDocument( + boost::shared_ptr theDoc, bool theSendSignal) { if (myCurrentDoc != theDoc) { myCurrentDoc = theDoc; - static boost::shared_ptr aMsg(new Events_Message(Events_Loop::eventByName("CurrentDocumentChanged"))); - Events_Loop::loop()->send(aMsg); + if (theSendSignal) { + static boost::shared_ptr aMsg(new Events_Message(Events_Loop::eventByName("CurrentDocumentChanged"))); + Events_Loop::loop()->send(aMsg); + } } } diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index e691cea30..fd4f9c0b5 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -73,7 +73,8 @@ class Model_Session : public ModelAPI_Session, public Events_Listener MODEL_EXPORT virtual boost::shared_ptr activeDocument(); /// Defines the current document that used for current work in the application - MODEL_EXPORT virtual void setActiveDocument(boost::shared_ptr theDoc); + MODEL_EXPORT virtual void setActiveDocument( + boost::shared_ptr theDoc, bool theSendSignal = true); /// Returns all the opened documents of the session (without postponed) MODEL_EXPORT virtual std::list > allOpenedDocuments(); diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index b5e4d5d3b..c97105421 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -75,7 +75,8 @@ class MODELAPI_EXPORT ModelAPI_Session virtual boost::shared_ptr activeDocument() = 0; /// Defines the current document that used for current work in the application - virtual void setActiveDocument(boost::shared_ptr theDoc) = 0; + virtual void setActiveDocument( + boost::shared_ptr theDoc, bool theSendSignal = true) = 0; /// Returns all the opened documents of the session (without postponed) virtual std::list > allOpenedDocuments() = 0; diff --git a/src/PartSetPlugin/PartSetPlugin_Part.cpp b/src/PartSetPlugin/PartSetPlugin_Part.cpp index 9c5e6e62a..48d338267 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Part.cpp @@ -27,16 +27,6 @@ void PartSetPlugin_Part::execute() setResult(aResult); aResult->activate(); } - /* - boost::shared_ptr aDocRef = aResult->data()->docRef( - ModelAPI_ResultPart::DOC_REF()); - - if (!aDocRef->value()) { // create a document if not yet created - boost::shared_ptr aPartSetDoc = - ModelAPI_Session::get()->moduleDocument(); - aDocRef->setValue(aPartSetDoc->subDocument(data()->name())); - } - */ } boost::shared_ptr PartSetPlugin_Part::documentToAdd() -- 2.39.2