]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for crashes on close of application in SALOME mode V_0.5.1
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 13 Nov 2014 11:16:01 +0000 (14:16 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 13 Nov 2014 11:16:01 +0000 (14:16 +0300)
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/XGUI/XGUI_DocumentDataModel.cpp

index d0e1d96ac401c354f1c4fe98b1504ba53ecf0845..2eb18737cdfe15ad5f210365252870dea2db3df9 100644 (file)
@@ -975,9 +975,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector<SketchSolver_Constrain
           isFound = (aGrEntIter->find(aConstrEnt[i]) != aGrEntIter->end());
           // Also we need to check sub-entities
           int aEntPos = Search(aConstrEnt[i], myEntities);
-          Slvs_hEntity* aSub = myEntities[aEntPos].point;
-          for (int j = 0; *aSub != 0 && j < 4 && !isFound; aSub++, j++)
-            isFound = (aGrEntIter->find(*aSub) != aGrEntIter->end());
+          if (aEntPos != myEntities.size()) { // MPV: to fix the crash on close
+            Slvs_hEntity* aSub = myEntities[aEntPos].point;
+            for (int j = 0; *aSub != 0 && j < 4 && !isFound; aSub++, j++)
+              isFound = (aGrEntIter->find(*aSub) != aGrEntIter->end());
+          }
         }
       if (isFound)
         anIndexes.push_back(aGrEntIter - aGroupsEntities.begin());
@@ -989,9 +991,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector<SketchSolver_Constrain
         if (aConstrEnt[i] != 0) {
           aNewGrEnt.insert(aConstrEnt[i]);
           int aEntPos = Search(aConstrEnt[i], myEntities);
-          Slvs_hEntity* aSub = myEntities[aEntPos].point;
-          for (int j = 0; *aSub != 0 && j < 4; aSub++, j++)
-            aNewGrEnt.insert(*aSub);
+          if (aEntPos != myEntities.size()) { // MPV: to fix the crash on close
+            Slvs_hEntity* aSub = myEntities[aEntPos].point;
+            for (int j = 0; *aSub != 0 && j < 4; aSub++, j++)
+              aNewGrEnt.insert(*aSub);
+          }
         }
       std::set<Slvs_hConstraint> aNewGrConstr;
       aNewGrConstr.insert(aConstrIter->h);
@@ -1006,9 +1010,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector<SketchSolver_Constrain
         if (aConstrEnt[i] != 0) {
           aGrEntIter->insert(aConstrEnt[i]);
           int aEntPos = Search(aConstrEnt[i], myEntities);
-          Slvs_hEntity* aSub = myEntities[aEntPos].point;
-          for (int j = 0; *aSub != 0 && j < 4; aSub++, j++)
-            aGrEntIter->insert(*aSub);
+          if (aEntPos != myEntities.size()) { // MPV: to fix the crash on close
+            Slvs_hEntity* aSub = myEntities[aEntPos].point;
+            for (int j = 0; *aSub != 0 && j < 4; aSub++, j++)
+              aGrEntIter->insert(*aSub);
+          }
         }
       aGroupsConstr[anIndexes.front()].insert(aConstrIter->h);
       if (aGrEntIter->size() > aGroupsEntities[aMaxNbEntities].size())
index 14a8735b1dcfaec4f4e236cf0c5f189ba3409ae8..42d96c8bebf2ccad848c317cdf8e2c8c679149ef 100644 (file)
@@ -108,12 +108,14 @@ void XGUI_DocumentDataModel::processEvent(const boost::shared_ptr<Events_Message
       if (aDoc == aRootDoc) {  // If root objects
         if (aGroup == ModelAPI_ResultPart::group()) {  // Update only Parts group
           int aStart = myPartModels.size() - 1;
-          removeSubModel(aStart);
-          removeRow(aStart, partFolderNode());
-          if (myActivePart && (!isPartSubModel(myActivePart))) {
-            myActivePart = 0;
-            myActivePartIndex = QModelIndex();
-            myModel->setItemsColor(ACTIVE_COLOR);
+          if (aStart >= 0) {// MPV: this could be reproduced on close
+            removeSubModel(aStart);
+            removeRow(aStart, partFolderNode());
+            if (myActivePart && (!isPartSubModel(myActivePart))) {
+              myActivePart = 0;
+              myActivePartIndex = QModelIndex();
+              myModel->setItemsColor(ACTIVE_COLOR);
+            }
           }
         } else {  // Update top groups (other except parts
           QModelIndex aIndex = myModel->findGroup(aGroup);