]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for exception on Delete object
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 20 Aug 2015 09:19:05 +0000 (12:19 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 20 Aug 2015 09:19:19 +0000 (12:19 +0300)
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index faf2891e3368ecdc84c299e1bb2d9ea31cf73a70..bba968407ebef090e0787c263d7b1a35d92cdfb1 100644 (file)
@@ -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<ModelAPI_Feature>(aObj);
     if (aFeature.get()) {
index 59c061997fcb464a9393729f9917db6cb4c934be..84b91bcf9e3d1d4b3f83dc87d3a0f8f141b3526c 100644 (file)
@@ -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);