Salome HOME
refs #441: crash in digue construction
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Tool.cxx
index 75526f52e295f1b136eb90d9b85a84d2875bb616..34f600f5cf43b907d6ab137c076f2f805b45739f 100644 (file)
@@ -31,6 +31,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Tool.h>
+#include <HYDROData_Profile.h>
 
 #include <GEOMBase.h>
 
@@ -693,16 +694,26 @@ QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& th
 }
 
 QStringList HYDROGUI_Tool::FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, 
-                                                     const ObjectKind theObjectKind )
+                                                     const ObjectKind theObjectKind,
+                                                     bool isCheckValidProfile )
 {
   QStringList aNames;
 
   HYDROData_Iterator anIter( theDoc, theObjectKind );
   for ( ; anIter.More(); anIter.Next() ) {
     Handle(HYDROData_Entity) anObject = anIter.Current();
-    if( !anObject.IsNull() ) {
-      aNames.append( anObject->GetName() );
+
+    bool isOK = !anObject.IsNull();
+    
+    if( isOK && isCheckValidProfile )
+    {
+      Handle_HYDROData_Profile aProfile = Handle_HYDROData_Profile::DownCast( anObject );
+      if( !aProfile.IsNull() && !aProfile->IsValid() )
+        isOK = false;
     }
+      
+    if( isOK )
+      aNames.append( anObject->GetName() );
   }
 
   return aNames;