Salome HOME
Issue #2349 Fatal error when close window Hide faces
authornds <nds@opencascade.com>
Thu, 7 Dec 2017 10:23:48 +0000 (13:23 +0300)
committernds <nds@opencascade.com>
Thu, 7 Dec 2017 10:23:48 +0000 (13:23 +0300)
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_FacesPanel.h

index 0c9124ff9c7c7bd1812684c9c398a4e57f175412..73e79adc91c9dc8b512b395aadce60ce45e20ccb 100644 (file)
@@ -84,7 +84,7 @@ void XGUI_FacesPanel::reset(const bool isToFlushRedisplay)
   // restore previous view of presentations
   bool isModified = redisplayObjects(myItemObjects, false);
   std::set<std::shared_ptr<ModelAPI_Object> > aHiddenObjects = myHiddenObjects;
-  isModified = displayHiddenObjects(aHiddenObjects, false) || isModified;
+  isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects, false) || isModified;
   if (isModified && isToFlushRedisplay)
     Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 
@@ -250,7 +250,8 @@ bool XGUI_FacesPanel::processDelete()
   }
   if (isModified) {
     bool isRedisplayed = redisplayObjects(aRestoredObjects, false);
-    isRedisplayed = displayHiddenObjects(aRestoredObjects, false) || isRedisplayed;
+    isRedisplayed = displayHiddenObjects(aRestoredObjects, myHiddenObjects, false)
+                    || isRedisplayed;
     if (isRedisplayed)
       Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
     // should be after flush of redisplay to have items object to be updated
@@ -291,6 +292,7 @@ bool XGUI_FacesPanel::redisplayObjects(
 //********************************************************************
 bool XGUI_FacesPanel::displayHiddenObjects(
   const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
+  std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects,
   const bool isToFlushRedisplay)
 {
   if (theObjects.empty())
@@ -304,9 +306,9 @@ bool XGUI_FacesPanel::displayHiddenObjects(
   {
     ObjectPtr anObject = *anIt;
     // if the object was hidden by this panel
-    if (anObject->isDisplayed() || myHiddenObjects.find(anObject) == myHiddenObjects.end())
+    if (anObject->isDisplayed() || theHiddenObjects.find(anObject) == theHiddenObjects.end())
       continue;
-    myHiddenObjects.erase(anObject);
+    theHiddenObjects.erase(anObject);
     anObject->setDisplayed(true); // it means that the object is hidden by hide all faces
     ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
     isModified = true;
@@ -461,7 +463,7 @@ void XGUI_FacesPanel::onTransparencyChanged()
   bool isModified = false;
   if (useTransparency()) {
     std::set<std::shared_ptr<ModelAPI_Object> > aHiddenObjects = myHiddenObjects;
-    isModified = displayHiddenObjects(aHiddenObjects, false);
+    isModified = displayHiddenObjects(aHiddenObjects, myHiddenObjects, false);
   }
   else
     isModified = hideEmptyObjects();
index 8b5d71a6b4b24f2367b448bcb548e6e6b33ba755..1dca0a9b0da8a064676c9c944a0d4d44b7b9d1ac 100644 (file)
@@ -148,15 +148,17 @@ private:
   /// \param theObjects container of objects
   /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
   /// \return true if some of objects was redisplayed
-  bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
-                        const bool isToFlushRedisplay);
+  static bool redisplayObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
+                               const bool isToFlushRedisplay);
 
   /// Display objects if the objects are in a container of hidden by this pane.
   /// \param theObjects container of objects
+  /// \param theHiddenObjects hidden objects, if object is in the container, it should be removed
   /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
   /// \return true if some of objects was redisplayed
-  bool displayHiddenObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
-                            const bool isToFlushRedisplay);
+  static bool displayHiddenObjects(const std::set<std::shared_ptr<ModelAPI_Object> >& theObjects,
+                                   std::set<std::shared_ptr<ModelAPI_Object> >& theHiddenObjects,
+                                   const bool isToFlushRedisplay);
 
   /// Iterates by items and hide objects where all sub-shapes are hidden
   /// \return true if some of objects was redisplayed