From: vsv Date: Thu, 20 Aug 2015 09:19:05 +0000 (+0300) Subject: Fix for exception on Delete object X-Git-Tag: V_1.4.0_beta4~325 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aef17ca40cfce34a2330a9fba7d4255aff21ab3b;p=modules%2Fshaper.git Fix for exception on Delete object --- diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index faf2891e3..bba968407 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -489,8 +489,13 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & } //****************************************************** +static QModelIndex MYLastDeleted; QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const { + // To avoid additional request about index which was already deleted + if (theIndex == MYLastDeleted) + return QModelIndex(); + int aId = theIndex.internalId(); if (aId != -1) { // The object is not a root folder ModelAPI_Document* aDoc = getSubDocument(theIndex.internalPointer()); @@ -499,6 +504,11 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const return findDocumentRootIndex(aDoc); } ObjectPtr aObj = object(theIndex); + if (!aObj.get()) { + // To avoid additional request about index which was already deleted + MYLastDeleted = theIndex; + return QModelIndex(); + } // Check is it object a sub-object of a complex object FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); if (aFeature.get()) { diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 59c061997..84b91bcf9 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1001,7 +1001,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) QObjectPtrList aObjects = mySelector->selection()->selectedObjects(); if (theId == "DELETE_CMD") deleteObjects(); - if (theId == "MOVE_CMD") + else if (theId == "MOVE_CMD") moveObjects(); else if (theId == "COLOR_CMD") changeColor(aObjects);