From: vsv Date: Mon, 8 Aug 2022 19:13:07 +0000 (+0300) Subject: bos #30735: [CEA] model.checkPythonDump() inconsistent X-Git-Tag: V9_9_1b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fshaper.git;a=commitdiff_plain;h=dad94b39de08a085af4f653d3470d4c3ea84bf41 bos #30735: [CEA] model.checkPythonDump() inconsistent --- diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp index ac429fb80..ce4a51bc2 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp @@ -139,9 +139,7 @@ void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionPtr anAttrCenterPoint = aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); - // for old versions radius value was located in another place, so, use the default 10 - double aRadValue = anAttrRadius->isInitialized() ? anAttrRadius->value() : 10; - theDumper << ", " << anAttrCenterPoint << ", " << aRadValue; + theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius; } theDumper << ")" << std::endl; diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index e1a9ba293..270fbe3f3 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -42,6 +42,20 @@ #pragma warning(disable: 4100) #endif +static bool isValidNode(const ModuleBase_ITreeNode* theNode) +{ + ModuleBase_ITreeNode* aParent = 0; + try { + aParent = theNode->parent(); + } + catch (...) { + return false; + } + if (aParent) + return isValidNode(aParent); + return true; +} + // Constructor ************************************************* XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent)//, //myIsEventsProcessingBlocked(false) @@ -367,7 +381,10 @@ bool XGUI_DataModel::removeRows(int theRow, int theCount, const QModelIndex& the Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const { if (theIndex.isValid()) { - ModuleBase_ITreeNode* aNode = (ModuleBase_ITreeNode*)theIndex.internalPointer(); + ModuleBase_ITreeNode* aNode = static_cast(theIndex.internalPointer()); + // Check that the pointer is Valid + if (!isValidNode(aNode)) + return Qt::NoItemFlags; Qt::ItemFlags aResultFlags = aNode->flags(theIndex.column()); // Drag and drop of Part features only if: // - PartSet is active