Salome HOME
bos #19219 [CEA] SIGSEGV when right-click in the view in 3D layers dialog box
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Selection.cxx
index d4b79054e6c4471eba61e351cedb3a3510685cb4..5abe5c5be61812c0d1b17777e7a921e28c191f5a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -613,9 +613,24 @@ bool SMESHGUI_Selection::hasGeomReference( int ind ) const
 
 bool SMESHGUI_Selection::canBreakLink( int ind ) const
 {
-  if ( ind >= 0 && ind < myTypes.count()) {
-    _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
-    return true;
+  if ( ind >= 0 && isReference(ind) ) {
+    QString aEntry = objectInfo(ind, OI_RefEntry).toString();
+    if (!aEntry.isEmpty()) {
+      _PTR(SObject) aSObject = SMESH::getStudy()->FindObjectID( aEntry.toStdString());
+      if (aSObject) {
+       _PTR(SObject) aFatherObj = aSObject->GetFather();
+       if (aFatherObj) {
+         _PTR(SComponent) aComponent = aFatherObj->GetFatherComponent();
+         if (aComponent && aComponent->ComponentDataType() == "SMESH") {
+           QString aObjEntry = entry(ind);
+           _PTR(SObject) aGeomSObject = SMESH::getStudy()->FindObjectID(aObjEntry.toStdString());
+           GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aGeomSObject);
+           if (!aObject->_is_nil())
+             return aObject->IsParametrical();
+          }
+        }
+      }
+    }
   }
   return false;
 }