]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Send groupped events in finishOperation() until they exist
authormpv <mpv@opencascade.com>
Fri, 31 Mar 2017 07:55:25 +0000 (10:55 +0300)
committerazv <azv@opencascade.com>
Fri, 31 Mar 2017 07:55:25 +0000 (10:55 +0300)
src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/Model/Model_Document.cpp

index 0d380b76b6df90ce014b9335b829327daf920ed9..7b9d16b1c1285c63c164f0cc971047b70d978a3e 100644 (file)
@@ -241,14 +241,6 @@ void Events_Loop::clear(const Events_ID& theID)
   }
 }
 
-void Events_Loop::autoFlush(const Events_ID& theID, const bool theAuto)
-{
-  if (theAuto)
-    myFlushed.insert(theID.myID);
-  else
-    myFlushed.erase(myFlushed.find(theID.myID));
-}
-
 bool Events_Loop::isFlushed(const Events_ID& theID)
 {
   return myFlushed.find(theID.myID) != myFlushed.end();
@@ -261,3 +253,8 @@ void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue)
   else
     myFlushed.erase(myFlushed.find(theID.myID));
 }
+
+bool Events_Loop::hasGrouppedEvent(const Events_ID& theID)
+{
+  return myGroups.find(theID.myID) != myGroups.end();
+}
\ No newline at end of file
index 69ea2ed2485e9ad15cbcf6fe07389c16f918e966..94122adbe03100e2d8bb37bb30b1ba58260f6250 100644 (file)
@@ -86,14 +86,14 @@ class Events_Loop
   //! Clears all collected messages
   EVENTS_EXPORT void clear(const Events_ID& theID);
 
-  //! Enables flush without grouping for the given message
-  EVENTS_EXPORT void autoFlush(const Events_ID& theID, const bool theAuto = true);
-
   //! Returns true if the evement is flushed right now
   EVENTS_EXPORT bool isFlushed(const Events_ID& theID);
   //! Sets the flag that the event is flished right now
   EVENTS_EXPORT void setFlushed(const Events_ID& theID, const bool theValue);
 
+  //! Returns true if a loop accumulated events to be flashed
+  EVENTS_EXPORT bool hasGrouppedEvent(const Events_ID& theID);
+
 private:
   //! Calls "processEvent" for the given listeners.
   //! If theFlushedNow for grouped listeners is stores message in listeners.
index ca4c907b001945e6f00a4d6e1d0b08b3e956f1e8..7c93ab7b596a35df445dca43627dc1d615ac12cd 100755 (executable)
@@ -557,10 +557,14 @@ bool Model_Document::finishOperation()
   }
   myObjs->synchronizeBackRefs();
   Events_Loop* aLoop = Events_Loop::loop();
-  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
-  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+  static const Events_ID kCreatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED);
+  static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
+  static const Events_ID kRedispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  static const Events_ID kDeletedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED);
+  aLoop->flush(kCreatedEvent);
+  aLoop->flush(kUpdatedEvent);
+  aLoop->flush(kRedispEvent);
+  aLoop->flush(kDeletedEvent);
 
   if (isNestedClosed) {
     if (myDoc->CommitCommand())
@@ -571,11 +575,19 @@ bool Model_Document::finishOperation()
   // to avoid messages about modifications outside of the transaction
   // and to rebuild everything after all updates and creates
   if (isRoot()) { // once for root document
-    Events_Loop::loop()->autoFlush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
     static std::shared_ptr<Events_Message> aFinishMsg
       (new Events_Message(Events_Loop::eventByName("FinishOperation")));
     Events_Loop::loop()->send(aFinishMsg);
   }
+
+  while(aLoop->hasGrouppedEvent(kCreatedEvent) || aLoop->hasGrouppedEvent(kUpdatedEvent) ||
+        aLoop->hasGrouppedEvent(kRedispEvent) || aLoop->hasGrouppedEvent(kDeletedEvent)) {
+    aLoop->flush(kCreatedEvent);
+    aLoop->flush(kUpdatedEvent);
+    aLoop->flush(kRedispEvent);
+    aLoop->flush(kDeletedEvent);
+  }
+
   // to avoid "updated" message appearance by updater
   //aLoop->clear(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
@@ -587,11 +599,6 @@ bool Model_Document::finishOperation()
     if (subDoc(*aSubIter)->finishOperation())
       aResult = true;
 
-  // sub-Part may send updated by flush of deleted (macro circle)
-  if (isRoot()) { // once for root document
-    Events_Loop::loop()->autoFlush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED), false);
-  }
-
   // transaction may be empty if this document was created during this transaction (create part)
   if (!myTransactions.empty() && myDoc->CommitCommand()) {
     // if commit is successfull, just increment counters