]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
bos #30735: [CEA] model.checkPythonDump() inconsistent 30735
authorvsv <vsv@opencascade.com>
Mon, 8 Aug 2022 19:13:07 +0000 (22:13 +0300)
committervsv <vsv@opencascade.com>
Mon, 8 Aug 2022 19:13:07 +0000 (22:13 +0300)
src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp
src/XGUI/XGUI_DataModel.cpp

index ac429fb80ca0e1fd20843bc58a9c9c15b88baa45..ce4a51bc261785fcd6cd2d435638605c9fd1c624 100644 (file)
@@ -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;
index e1a9ba2933eebb4c1faae09b7ad9b689a8e9426b..270fbe3f37bd557beed02df2a0ab7e110e93c101 100644 (file)
 #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<ModuleBase_ITreeNode*>(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