From: vsv Date: Fri, 4 Sep 2015 09:53:18 +0000 (+0300) Subject: Check a case when created object can be canceled X-Git-Tag: V_1.4.0_beta4~124 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=88d06aba0ec66a3d985e6901ae08ec22c9533ddb;p=modules%2Fshaper.git Check a case when created object can be canceled --- diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 7d1a27cd5..bc407998b 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -101,14 +101,16 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess } // Insert new object int aRow = aRootDoc->size(aObjType) - 1; - if (aObjType == aRootType) { - insertRow(aRow + aNbFolders + 1); - } else { - int aFolderId = myXMLReader.rootFolderId(aObjType); - if (aFolderId != -1) { - insertRow(aRow, createIndex(aFolderId, 0, -1)); - } - } + if (aRow != -1) { + if (aObjType == aRootType) { + insertRow(aRow + aNbFolders + 1); + } else { + int aFolderId = myXMLReader.rootFolderId(aObjType); + if (aFolderId != -1) { + insertRow(aRow, createIndex(aFolderId, 0, -1)); + } + } + } } else { // Object created in sub-document QModelIndex aDocRoot = findDocumentRootIndex(aDoc.get()); @@ -121,18 +123,20 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess insertRow(myXMLReader.subFolderId(aObjType), aDocRoot); } int aRow = aDoc->index(aObject); - int aNbSubFolders = foldersCount(aDoc.get()); - if (aObjType == aSubType) { - // List of objects under document root - insertRow(aRow + aNbSubFolders, aDocRoot); - } else { - // List of objects under a folder - if (aRow != -1) { - int aFolderId = folderId(aObjType, aDoc.get()); - if (aFolderId != -1) { - QModelIndex aParentFolder = createIndex(aFolderId, 0, aDoc.get()); - insertRow(aRow, aParentFolder); - emit dataChanged(aParentFolder, aParentFolder); + if (aRow != -1) { + int aNbSubFolders = foldersCount(aDoc.get()); + if (aObjType == aSubType) { + // List of objects under document root + insertRow(aRow + aNbSubFolders, aDocRoot); + } else { + // List of objects under a folder + if (aRow != -1) { + int aFolderId = folderId(aObjType, aDoc.get()); + if (aFolderId != -1) { + QModelIndex aParentFolder = createIndex(aFolderId, 0, aDoc.get()); + insertRow(aRow, aParentFolder); + emit dataChanged(aParentFolder, aParentFolder); + } } } }