From 756e01646844fa169efde2e4f81b26262f37431f Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 25 Dec 2017 15:58:44 +0300 Subject: [PATCH] Issue #2360: Clear current selection before change of selection type because it could cause crash because of obsolete index update in Object Browser --- src/Model/Model_Objects.cpp | 4 ++-- src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 6f5c45a21..2dc014a40 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -593,8 +593,8 @@ ObjectPtr Model_Objects::object(const std::string& theGroupID, createHistory(theGroupID); const std::string& aGroupID = groupNameFoldering(theGroupID, theAllowFolder); const std::vector& aVec = myHistory[theGroupID]; - if (aVec.size() <= theIndex) - return aVec[aVec.size() - 1]; // too high index requested (to avoid crash in #2360) + //if (aVec.size() <= theIndex) + // return aVec[aVec.size() - 1]; // too high index requested (to avoid crash in #2360) return aGroupID.empty() ? myHistory[theGroupID][theIndex] : myHistory[aGroupID][theIndex]; } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index de224116c..407a59339 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -435,6 +435,11 @@ QList ModuleBase_WidgetMultiSelector::getControls() const //******************************************************************** void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged() { + // Clear current selection in order to avoid updating of object browser with obsolete indexes + // which can appear because of results deletetion after changing a type of selection + QList aEmptyList; + myWorkshop->setSelected(aEmptyList); + updateSelectionModesAndFilters(true); myWorkshop->selectionActivate()->updateSelectionModes(); -- 2.30.2