Salome HOME
Fix for the issue #1647 : problem with OB when sub-features are created.
authormpv <mpv@opencascade.com>
Tue, 30 Aug 2016 14:52:45 +0000 (17:52 +0300)
committermpv <mpv@opencascade.com>
Tue, 30 Aug 2016 14:53:02 +0000 (17:53 +0300)
src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/Model/Model_Update.cpp
src/ModelHighAPI/ModelHighAPI_Services.cpp
src/XGUI/XGUI_DataModel.cpp

index b969741898d7840069eb08572de5ea7b4fd6e794..e68798aa43c31f7e341af66bd32d60aba00f37f0 100644 (file)
@@ -62,8 +62,6 @@ void Events_Loop::send(const std::shared_ptr<Events_Message>& theMessage, bool i
     }
   }
 
-  // TODO: make it in thread and with usage of semaphores
-
   map<char*, map<void*, list<Events_Listener*> > >::iterator aFindID = myListeners.find(
       theMessage->eventID().eventText());
   if (aFindID != myListeners.end()) {
index c1c5f2977a0c08edb95c5ca28da2411d2172a23d..0d1f729bd2442cf59b95681f9e81b8b4faf40d82 100644 (file)
@@ -60,8 +60,12 @@ class Events_Loop
 
   //! Registers (or adds if such listener is already registered) a listener 
   //! that will be called on the event and from the defined sender
+  //! \param theListener the object that will listen (process) the event
+  //! \param theID listen for messages with this ID
+  //! \param theSender listen only for this sender (NULL - listen everybody)
+  //! \param theImmediate for listeners who can not wait (no groupping mechanism is used for it)
   EVENTS_EXPORT void registerListener(Events_Listener* theListener, const Events_ID theID,
-                                      void* theSender = 0, bool theImmediate = false);
+    void* theSender = 0, bool theImmediate = false);
 
   //! Remove the listener from internal maps if it was registered there
   //! \param theListener a listener
index d5eaf23603fbf028461b5a8a289d1b9f2995b5cf..4107115ce918ce816768289e9e340a3442d3bf73 100644 (file)
@@ -187,6 +187,9 @@ void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName)
       aSelectionList->value(anElementIndex)->setId(aReferenceID);
     }
   }
+  // Top avoid problems in Object Browser update: issue #1647.
+  ModelAPI_EventCreator::get()->sendReordered(
+    std::dynamic_pointer_cast<ModelAPI_Feature>(aRefListOfGroups->owner()));
 
   } catch (XAO::XAO_Exception& e) {
     std::string anError = e.what();
index c081fbd7079b1dd1691ccb4a116d7452dad0d93e..48b8dcb00cb5284405ef05d0d77f2b705f9cbf49 100755 (executable)
@@ -310,7 +310,8 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
   } else if (theMessage->eventID() == kReorderEvent) {
     std::shared_ptr<ModelAPI_OrderUpdatedMessage> aMsg = 
       std::dynamic_pointer_cast<ModelAPI_OrderUpdatedMessage>(theMessage);
-    addModified(aMsg->reordered(), aMsg->reordered()); // to update all attributes
+    if (aMsg->reordered().get())
+      addModified(aMsg->reordered(), aMsg->reordered()); // to update all attributes
   }
 }
 
index c1c6e64b3a1d1f5f4df34ccf2f12bf2f40c0a0ee..4b40b09e1d32f9ea251a93656d2c660137431d15 100644 (file)
@@ -12,6 +12,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Events.h>
 
 #include <cmath>
 
@@ -84,9 +85,12 @@ void begin()
 {
   ModelAPI_Session::get()->startOperation();
 }
+
 void end()
 {
   ModelAPI_Session::get()->finishOperation();
+  // to update data tree in the end of dumped script execution
+  ModelAPI_EventCreator::get()->sendReordered(FeaturePtr());
 }
 void apply()
 {
index cc80025fb8a98e5f59e6a9504c813ba226f625b1..3d14d5108b9bdb4d713db9b95384deb904c3d20d 100644 (file)
@@ -255,29 +255,33 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) {
     std::shared_ptr<ModelAPI_OrderUpdatedMessage> aUpdMsg =
         std::dynamic_pointer_cast<ModelAPI_OrderUpdatedMessage>(theMessage);
-    DocumentPtr aDoc = aUpdMsg->reordered()->document();
-    std::string aGroup = aUpdMsg->reordered()->group();
-
-    QModelIndex aParent;
-    int aStartId = 0;
-    if (aDoc == aRootDoc) {
-      // Update a group under root
-      if (aGroup == myXMLReader->rootType()) // Update objects under root
-        aStartId = foldersCount();
-      else // Update objects in folder under root 
-        aParent = createIndex(folderId(aGroup), 0, -1);
+    if (aUpdMsg->reordered().get()) {
+      DocumentPtr aDoc = aUpdMsg->reordered()->document();
+      std::string aGroup = aUpdMsg->reordered()->group();
+
+      QModelIndex aParent;
+      int aStartId = 0;
+      if (aDoc == aRootDoc) {
+        // Update a group under root
+        if (aGroup == myXMLReader->rootType()) // Update objects under root
+          aStartId = foldersCount();
+        else // Update objects in folder under root 
+          aParent = createIndex(folderId(aGroup), 0, -1);
+      } else {
+        // Update a sub-document
+        if (aGroup == myXMLReader->subType()) {
+          // Update sub-document root
+          aParent = findDocumentRootIndex(aDoc.get());
+          aStartId = foldersCount(aDoc.get());
+        } else 
+          // update folder in sub-document
+          aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+      }
+      int aChildNb = rowCount(aParent);
+      rebuildBranch(aStartId, aChildNb - aStartId, aParent);
     } else {
-      // Update a sub-document
-      if (aGroup == myXMLReader->subType()) {
-        // Update sub-document root
-        aParent = findDocumentRootIndex(aDoc.get());
-        aStartId = foldersCount(aDoc.get());
-      } else 
-        // update folder in sub-document
-        aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+      rebuildDataTree();
     }
-    int aChildNb = rowCount(aParent);
-    rebuildBranch(aStartId, aChildNb - aStartId, aParent);
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
     DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
     if (aDoc != aRootDoc) {