]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1404 Random crash with Shaper. REDISPLAY is not flushed in deleteFeature....
authornds <nds@opencascade.com>
Fri, 15 Apr 2016 08:54:28 +0000 (11:54 +0300)
committernds <nds@opencascade.com>
Fri, 15 Apr 2016 09:11:01 +0000 (12:11 +0300)
Additionaly performance of fillet, mirror, rotation are improved by this modification.

src/Model/Model_Document.h
src/Model/Model_Objects.cpp
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/PartSet/PartSet_Module.cpp
src/PartSetPlugin/PartSetPlugin_Part.cpp
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 312472a8d4cf3919a2330695fb8b741de34f6044..f76c3cf27d2816a3ead1942255863735b61779ca 100644 (file)
@@ -90,6 +90,8 @@ class Model_Document : public ModelAPI_Document
                                           const bool isSendError = true);
 
   //! Removes the feature from the document (with result)
+  //! It is necessary to flush REDISPLAY signal manually after this method because
+  //! the method sends it, but for the performance purpose does not flush it
   //! \param theFeature a removed feature
   MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature);
 
index e2eeeea2e2f30f150c96d9912a57ff31b4c80b3c..fa69915828b7bc6bf24d2161bc682ee5a25404ab 100644 (file)
@@ -263,8 +263,6 @@ void Model_Objects::removeFeature(FeaturePtr theFeature)
     RemoveFromRefArray(featuresLabel(), aFeatureLabel);
     // event: feature is deleted
     ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), ModelAPI_Feature::group());
-    // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
-    Events_Loop::loop()->flush(EVENT_DISP);
     updateHistory(ModelAPI_Feature::group());
   }
 }
index d49990aa5b267fd9b3e2b64e58136f3cf50f281a..c8ca55d4b261ad5d9758b30696f4bb72093e2981 100644 (file)
@@ -253,7 +253,7 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
     myProcessOnFinish.clear(); // processed features must be only on finish, so clear anyway (to avoid reimport on load)
 
     if (!(theMessage->eventID() == kOpStartEvent)) {
-      processFeatures();
+      processFeatures(false);
     }
     // remove all macros before clearing all created
     std::set<FeaturePtr>::iterator anUpdatedIter = myWaitForFinish.begin();
@@ -275,13 +275,18 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
         anUpdatedIter++;
       }
     }
+    // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
+    // if should be done after removeFeature() of document,
+    // by this reason, upper processFeatures() do not perform this flush
+    Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
     // in the end of transaction everything is updated, so clear the old objects
     myIsParamUpdated = false;
     myWaitForFinish.clear();
   }
 }
 
-void Model_Update::processFeatures()
+void Model_Update::processFeatures(const bool theFlushRedisplay)
 {
    // perform update of everything if it is not performed right now or any preview is blocked
   if (!myIsProcessed && !myIsPreviewBlocked) {
@@ -303,8 +308,10 @@ void Model_Update::processFeatures()
     aLoop->flush(kUpdatedEvent);
 
     // flush to update display
-    static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
-    aLoop->flush(EVENT_DISP);
+    if (theFlushRedisplay) {
+      static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+      aLoop->flush(EVENT_DISP);
+    }
     #ifdef DEB_UPDATE
       std::cout<<"****** End processing"<<std::endl;
     #endif
index f0586c9a25cb23a012246de77e4ca827a9c1992f..50199c8c3a97e28cc45312b7849a9cfbb719dc96 100644 (file)
@@ -73,7 +73,8 @@ protected:
 
   /// On operation start/end/abort the "Just" fileds must be cleared and processed in the right way
   /// \param theFinish is true for start, close or abort transaction: all objects must be processed
-  void processFeatures();
+  //! \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
+  void processFeatures(const bool theFlushRedisplay = true);
 
   /// Performs the feature execution
   /// \returns the status of execution
index f8b2fb3eee6c357df9c5ef305b16b9366cb8d491..5cf3d5e5a014f953406504e9f5325cce392fd0b1 100755 (executable)
@@ -68,6 +68,7 @@
 #include <XGUI_DataModel.h>
 #include <XGUI_ErrorMgr.h>
 #include <XGUI_CustomPrs.h>
+#include <XGUI_SelectionMgr.h>
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Sketch.h>
@@ -767,6 +768,11 @@ bool PartSet_Module::deleteObjects()
 
     anOpMgr->startOperation(anOpAction);
 
+    // WORKAROUND, should be done to avoid viewer highlight update after deletetion of objects
+    // the problem is in AIS Dimensions recompute if a line and the dim are removed, line is the first
+    // it causes the AIS recompute, where the base line is null, the result is empty AIS in the viewer
+    XGUI_Tools::workshop(myWorkshop)->selector()->clearSelection();
+
     // 4. delete features
     // sketch feature should be skipped, only sub-features can be removed
     // when sketch operation is active
index 31759862f1fe20f53d1bc72133dc191f94c8772e..c40a0eadf3d87fec1a2374001f2e0762cba98d77 100644 (file)
@@ -108,10 +108,4 @@ bool PartSetPlugin_Part::isSub(ObjectPtr theObject) const
 
 void PartSetPlugin_Part::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
 {
-  ResultPartPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultPart>(firstResult());
-  if (aResult.get()) {
-    DocumentPtr aDoc = aResult->partDoc();
-    if (aDoc.get() && aDoc->isOpened())
-      aDoc->removeFeature(theFeature);
-  }
 }
index d74666a65b208b0ee6bee701ff630f5e2942fd6d..a1c7bcfda295ab77636711299d7130911498015e 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "PartSetPlugin_Remove.h"
 #include "PartSetPlugin_Part.h"
+
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
@@ -13,6 +14,9 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_Events.h>
+
+#include <Events_Loop.h>
 
 void PartSetPlugin_Remove::execute()
 {
@@ -27,8 +31,12 @@ void PartSetPlugin_Remove::execute()
       aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close();
       std::set<std::shared_ptr<ModelAPI_Feature> > aRefFeatures;
       aRoot->refsToFeature(aFeature, aRefFeatures);
-      if (aRefFeatures.empty())
+      if (aRefFeatures.empty()) {
         aRoot->removeFeature(aFeature);
+        // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
+        // after removeFeature from the document
+        Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+      }
     }
   }
 }
index 1b601779cb90bd5dfe71f1dad10881a8fae953e2..4949ecd94f016084cc778f63384fc13ebfe92730 100755 (executable)
@@ -1386,7 +1386,7 @@ void XGUI_Workshop::cleanHistory()
     mySelector->clearSelection();
 
     std::set<FeaturePtr> anIgnoredFeatures;
-    if (removeFeatures(anUnusedObjects, anIgnoredFeatures, anActionId)) {
+    if (removeFeatures(anUnusedObjects, anIgnoredFeatures, anActionId, true)) {
       operationMgr()->commitOperation();
     }
     else {
@@ -1565,6 +1565,7 @@ bool XGUI_Workshop::deleteFeaturesInternal(const QObjectPtrList& theList,
                                            const std::set<FeaturePtr>& theIgnoredFeatures,
                                            const bool doDeleteReferences)
 {
+  bool isDone = false;
   if (doDeleteReferences) {
     std::set<FeaturePtr> aFeaturesToDelete = aDirectRefFeatures;
     aFeaturesToDelete.insert(aIndirectRefFeatures.begin(), aIndirectRefFeatures.end());
@@ -1577,7 +1578,9 @@ bool XGUI_Workshop::deleteFeaturesInternal(const QObjectPtrList& theList,
       FeaturePtr aFeature = (*anIt);
       DocumentPtr aDoc = aFeature->document();
       if (theIgnoredFeatures.find(aFeature) == theIgnoredFeatures.end()) {
+        // flush REDISPLAY signal after remove feature
         aDoc->removeFeature(aFeature);
+        isDone = true;
 #ifdef DEBUG_DELETE
         anInfo.append(ModuleBase_Tools::objectInfo(aFeature).toStdString().c_str());
 #endif
@@ -1590,13 +1593,21 @@ bool XGUI_Workshop::deleteFeaturesInternal(const QObjectPtrList& theList,
   }
 
   QString anActionId = "DELETE_CMD";
-  return removeFeatures(theList, theIgnoredFeatures, anActionId);
+  isDone = removeFeatures(theList, theIgnoredFeatures, anActionId, false) || isDone;
+
+  if (isDone) {
+    // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
+    // if should be done after removeFeature() of document
+    Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  }
+  return isDone;
 }
 
 //**************************************************************
 bool XGUI_Workshop::removeFeatures(const QObjectPtrList& theList,
                                    const std::set<FeaturePtr>& theIgnoredFeatures,
-                                   const QString& theActionId)
+                                   const QString& theActionId,
+                                   const bool theFlushRedisplay)
 {
   bool isDone = false;
 
@@ -1624,11 +1635,18 @@ bool XGUI_Workshop::removeFeatures(const QObjectPtrList& theList,
         anInfo.append(anInfoStr);
         qDebug(QString("remove feature :%1").arg(anInfoStr).toStdString().c_str());
 #endif
+        // flush REDISPLAY signal after remove feature
         aDoc->removeFeature(aFeature);
         isDone = true;
       }
     }
   }
+  if (isDone && theFlushRedisplay) {
+    // the redisplay signal should be flushed in order to erase the feature presentation in the viewer
+    // if should be done after removeFeature() of document
+    Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  }
+
 #ifdef DEBUG_DELETE
   qDebug(QString("remove features:%1").arg(anInfo.join("; ")).toStdString().c_str());
 #endif
index 0c09e08736a166c631d83119facf27d5a5243485..6cbc1429cf5a06a7e16b1a7aeab7a6f48bf55e84 100755 (executable)
@@ -504,9 +504,11 @@ private:
   //! \param theList an objects to be deleted
   //! \param theIgnoredFeatures a list of features to be ignored during delete
   //! \param theActionId an action command key to find context menu object types enabled for remove
+  //! \param theFlushRedisplay a boolean value if the redisplay signal should be flushed
   bool removeFeatures(const QObjectPtrList& theList,
                       const std::set<FeaturePtr>& theIgnoredFeatures,
-                      const QString& theActionId);
+                      const QString& theActionId,
+                      const bool theFlushRedisplay);
 
   //! Creates list of actions (commands) by given history list from session
   QList<ActionInfo> processHistoryList(const std::list<std::string>&) const;