]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for bug 10938: 'Copy', 'Paste' are active after application start.
authorjfa <jfa@opencascade.com>
Thu, 15 Dec 2005 13:56:05 +0000 (13:56 +0000)
committerjfa <jfa@opencascade.com>
Thu, 15 Dec 2005 13:56:05 +0000 (13:56 +0000)
src/SalomeApp/SalomeApp_Application.cxx

index b985f077d006d5c8dfaa3542ba287f3227346e3d..690b13b52ce9fa7be7a45b180ce636e13fdfec4c 100644 (file)
@@ -348,41 +348,33 @@ void SalomeApp_Application::onSelectionChanged()
    LightApp_SelectionMgr* mgr = selectionMgr();
    mgr->selectedObjects(list);
 
-   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
-   if(study == NULL) return;
+   bool canCopy  = false;
+   bool canPaste = false;
 
-   _PTR(Study) stdDS = study->studyDS();
-   if(!stdDS) return;
+   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+   if (study != NULL) {
+     _PTR(Study) stdDS = study->studyDS();
 
-   QAction* qaction;
+     if (stdDS) {
+       SALOME_ListIteratorOfListIO it ( list );
 
-   SALOME_ListIteratorOfListIO it( list );
-   if(it.More() && list.Extent() == 1)
-   {
-      _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
+       if (it.More() && list.Extent() == 1) {
+         _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
 
-      qaction = action(EditCopyId);
-      if( so ) {
-        SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
-        if ( aSO && studyMgr()->CanCopy(so) ) qaction->setEnabled(true);  
-        else qaction->setEnabled(false);
-      }
-      else qaction->setEnabled(false);
+         if ( so ) {
+           SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
 
-      qaction = action(EditPasteId);
-      if( so ) {
-        SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(so.get());
-        if( aSO && studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
-        else qaction->setEnabled(false);
-      }
-      else qaction->setEnabled(false);
-   }
-   else {
-     qaction = action(EditCopyId);
-     qaction->setEnabled(false);
-     qaction = action(EditPasteId);
-     qaction->setEnabled(false);
+           if ( aSO ) {
+             canCopy = studyMgr()->CanCopy(so);
+             canPaste = studyMgr()->CanPaste(so);
+           }
+         }
+       }
+     }
    }
+
+   action(EditCopyId)->setEnabled(canCopy);
+   action(EditPasteId)->setEnabled(canPaste);
 }
 
 /*!Delete references.*/