X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Application.cpp;h=4dddb449daf686c24185616677b8f45a6df6bed1;hb=dc19b4c930a9c2cf5db509fc81586deab00e7417;hp=f8955ce59d5da228b8bd276828f1a1a914f6a964;hpb=0c0573f4321deb94f9c5d3182a34fb672cc6e1f0;p=modules%2Fshaper.git diff --git a/src/Model/Model_Application.cpp b/src/Model/Model_Application.cpp index f8955ce59..4dddb449d 100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@ -30,19 +30,22 @@ const std::shared_ptr& Model_Application::getDocument(string the static const std::string thePartSetKind("PartSet"); static const std::string thePartKind("Part"); + bool isRoot = theDocID == "root"; // the document is root std::shared_ptr aNew( - new Model_Document(theDocID, theDocID == "root" ? thePartSetKind : thePartKind)); + new Model_Document(theDocID, isRoot ? thePartSetKind : thePartKind)); myDocs[theDocID] = aNew; - Events_ID anId = ModelAPI_DocumentCreatedMessage::eventId(); - std::shared_ptr aMessage = - std::shared_ptr(new ModelAPI_DocumentCreatedMessage(anId, this)); - aMessage->setDocument(aNew); - Events_Loop::loop()->send(aMessage); // load it if it must be loaded by demand if (myLoadedByDemand.find(theDocID) != myLoadedByDemand.end() && !myPath.empty()) { - aNew->load(myPath.c_str()); + aNew->load(myPath.c_str(), aNew); myLoadedByDemand.erase(theDocID); // done, don't do it anymore + } else { + aNew->setThis(aNew); + static Events_ID anId = ModelAPI_DocumentCreatedMessage::eventId(); + std::shared_ptr aMessage = std::shared_ptr + (new ModelAPI_DocumentCreatedMessage(anId, this)); + aMessage->setDocument(aNew); + Events_Loop::loop()->send(aMessage); } return myDocs[theDocID]; @@ -59,6 +62,10 @@ void Model_Application::deleteDocument(string theDocID) void Model_Application::deleteAllDocuments() { + std::map >::iterator aDoc = myDocs.begin(); + for(; aDoc != myDocs.end(); aDoc++) { + aDoc->second->close(true); + } myDocs.clear(); myLoadedByDemand.clear(); }