Salome HOME
NPAL19658: Deletion problem. Invalid actions were called by shortcuts.
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI.cxx
index abac1b184cd736cf987fbf36cd2dcb1866b478ba..7d4dd1f24c92e72d7a9f0b90230c39683750a612 100644 (file)
@@ -77,7 +77,8 @@ static QString getFileName( QWidget*           parent,
                             const QStringList  filters,
                            const QString&     caption,
                            bool               open,
-                           QString&           format )
+                           QString&           format,
+                           bool               showCurrentDirInitially = false)
 {
   static QString lastUsedFilter;
   //QStringList filters;
@@ -94,7 +95,9 @@ static QString getFileName( QWidget*           parent,
   if ( !caption.isEmpty() )
     fd->setCaption( caption );
 
-  if ( !initial.isEmpty() )
+  if ( showCurrentDirInitially && SUIT_FileDlg::getLastVisitedPath().isEmpty() )
+    fd->setSelection( QDir::currentDirPath() );
+  else if ( !initial.isEmpty() )
     fd->setSelection( initial );
 
   fd->setFilters( filters );
@@ -411,14 +414,21 @@ void GEOMToolsGUI::OnEditDelete()
            continue;
 
           //If the object has been used to create another one,then it can't be deleted 
-          _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom));
-          for ( it->InitEx( true ); it->More(); it->Next() ) {
+         //          _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom));
+           //    for ( it->InitEx( true ); it->More(); it->Next() ) {
+
+         for (_PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom)); it->More(); it->Next()) {
              _PTR(SObject) chobj (it->Value());
             if(CheckSubObjectInUse(chobj, obj, aStudy)) return;
             //check subobjects
             for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
               _PTR(SObject) child (it->Value());
               if(CheckSubObjectInUse( chobj, child, aStudy)) return;
+              //check subchildobject
+              for (_PTR(ChildIterator) it (aStudy->NewChildIterator(child)); it->More(); it->Next()) {
+                _PTR(SObject) subchildobj (it->Value());
+                if(CheckSubObjectInUse( chobj, subchildobj, aStudy)) return;
+              }
             }
           }
 
@@ -537,9 +547,9 @@ bool GEOMToolsGUI::Import()
   }
 
   QString fileType;
-
-  QString fileName = getFileName(app->desktop(), QDir::currentDirPath(), aMap, filters,
-                                 tr("GEOM_MEN_IMPORT"), true, fileType);
+  
+  QString fileName = getFileName(app->desktop(), "", aMap, filters,
+                                 tr("GEOM_MEN_IMPORT"), true, fileType, true);
 
   if (fileType.isEmpty() )
     {
@@ -790,14 +800,16 @@ bool GEOMToolsGUI::CheckSubObjectInUse(_PTR(SObject) checkobj,
 {
   CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(checkobj);
   GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
-  if( CORBA::is_nil(geomObj) ) 
+
+  CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(remobj);
+  GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
+
+  if( CORBA::is_nil(geomObj) || CORBA::is_nil(geomObj_rem)) 
     return false;
 
   GEOM::ListOfGO_var list = geomObj->GetDependency();
-  if( list->length() > 1 )
+  if( list->length() > 0 )
     for(int i = 0; i < list->length(); i++ ){
-      CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(remobj);
-      GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
       if( list[i]->_is_equivalent( geomObj_rem ) ){
        SalomeApp_Application* app =
          dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );