From 807b0a6865b7adc824b0598dd267168b3f64a823 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 13 Nov 2014 14:16:01 +0300 Subject: [PATCH] Fix for crashes on close of application in SALOME mode --- .../SketchSolver_ConstraintGroup.cpp | 24 ++++++++++++------- src/XGUI/XGUI_DocumentDataModel.cpp | 14 ++++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index d0e1d96ac..2eb18737c 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -975,9 +975,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorfind(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 aNewGrConstr; aNewGrConstr.insert(aConstrIter->h); @@ -1006,9 +1010,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorinsert(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()) diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 14a8735b1..42d96c8be 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -108,12 +108,14 @@ void XGUI_DocumentDataModel::processEvent(const boost::shared_ptrsetItemsColor(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); -- 2.39.2