]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid crash on using of wrong folder as a model for opening
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 18 Sep 2015 11:48:39 +0000 (14:48 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 18 Sep 2015 11:48:51 +0000 (14:48 +0300)
src/Model/Model_Document.cpp
src/XGUI/XGUI_DataModel.cpp

index 4ff65b48c699da6b4d07e62764f267cd22fdebf1..6c7ea7a3ca80de9c4208949e5af8fbcfdd3bcc27 100644 (file)
@@ -168,12 +168,12 @@ bool Model_Document::load(const char* theFileName, DocumentPtr theThis)
         break;
     }
   }
+  std::shared_ptr<Model_Session> aSession = 
+    std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
   if (!isError) {
     myDoc = aLoaded;
     myDoc->SetUndoLimit(UNDO_LIMIT);
     // to avoid the problem that feature is created in the current, not this, document
-    std::shared_ptr<Model_Session> aSession = 
-      std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
     aSession->setActiveDocument(anApp->getDocument(myID), false);
     aSession->setCheckTransactions(false);
     if (myObjs)
@@ -187,11 +187,7 @@ bool Model_Document::load(const char* theFileName, DocumentPtr theThis)
     // this is done in Part result "activate", so no needed here. Causes not-blue active part.
     // aSession->setActiveDocument(anApp->getDocument(myID), true);
   } else { // open failed, but new documnet was created to work with it: inform the model
-    static std::shared_ptr<Events_Message> aMsg(
-        new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)));
-    Events_Loop::loop()->send(aMsg);
-    TDF_LabelList anEmpty;
-    myObjs->synchronizeFeatures(anEmpty, true, true);
+    aSession->setActiveDocument(Model_Session::get()->moduleDocument(), false);
   } 
   return !isError;
 }
index 704fd0738e75187c4a49f7ef50e1c35d4eb8747f..2485d367c8f15e75dc8d37b20d01bfa341370208 100644 (file)
@@ -266,10 +266,13 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
       QModelIndex aDocRoot = findDocumentRootIndex(aDoc.get());
       if (aDocRoot.isValid())
         emit dataChanged(aDocRoot, aDocRoot);
-#ifdef _DEBUG
-      else
-        Events_Error::send("Problem with Data Model definition of sub-document");
-#endif
+      else 
+        // We have got a new document
+        rebuildDataTree();
+//#ifdef _DEBUG
+//      else
+//        Events_Error::send("Problem with Data Model definition of sub-document");
+//#endif
     }
   } 
 }
@@ -283,7 +286,8 @@ void XGUI_DataModel::clear()
 //******************************************************
 void XGUI_DataModel::rebuildDataTree()
 {
-
+  beginResetModel();
+  endResetModel();
 }
 
 //******************************************************