From: azv Date: Fri, 15 Dec 2017 11:20:55 +0000 (+0300) Subject: Issue #2371: Fatal error when undo/redo delete folder X-Git-Tag: V_2.10.0RC~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=98bbaec69e8312b8869ed33f8aeac7709983feb0;p=modules%2Fshaper.git Issue #2371: Fatal error when undo/redo delete folder --- diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index baf49e20b..b4ee3b011 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -376,8 +376,11 @@ ObjectPtr XGUI_DataModel::object(const QModelIndex& theIndex) const { if (theIndex.internalId() == 0) // this is a folder return ObjectPtr(); - ModelAPI_Object* aObj = - dynamic_cast((ModelAPI_Entity*)theIndex.internalPointer()); + ModelAPI_Object* aObj = 0; + try { + aObj = dynamic_cast((ModelAPI_Entity*)theIndex.internalPointer()); + } catch(...) {} + if (!aObj) return ObjectPtr(); if (getSubDocument(aObj)) // the selected index is a folder of sub-document @@ -760,9 +763,12 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const ObjectPtr aObj = object(theIndex); if (!aObj.get()) { // It can be a step of a field - ModelAPI_ResultField::ModelAPI_FieldStep* aStep = - dynamic_cast - ((ModelAPI_Entity*)theIndex.internalPointer()); + ModelAPI_ResultField::ModelAPI_FieldStep* aStep = 0; + try { + aStep = dynamic_cast + ((ModelAPI_Entity*)theIndex.internalPointer()); + } catch(...) {} + if (aStep) { ModelAPI_ResultField* aField = aStep->field(); DocumentPtr aDoc = aSession->activeDocument();