]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Modified method SetCurrentStudy, enclosed GUI calls in SALOME_Event.
authorsrn <srn@opencascade.com>
Wed, 29 Jun 2005 06:53:20 +0000 (06:53 +0000)
committersrn <srn@opencascade.com>
Wed, 29 Jun 2005 06:53:20 +0000 (06:53 +0000)
src/VISU_I/VISU_Gen_i.cc

index 0df04a876029bd32e1e299b0cb16bb71c754a8cc..a6a499534b3cd652517d064ebdb9ce95acf4ad44 100644 (file)
@@ -406,6 +406,39 @@ namespace VISU{
 
   void VISU_Gen_i::SetCurrentStudy (SALOMEDS::Study_ptr theStudy)
   {
+    class TEvent: public SALOME_Event { 
+      QString myStudyName;
+    public:
+      TEvent(const QString& theStudyName):myStudyName(theStudyName) 
+       {}  
+      virtual void Execute()
+       {
+         bool isActive = false;
+         SUIT_Session* aSession = SUIT_Session::session();
+         QPtrList<SUIT_Application> anApplications = aSession->applications();
+         QPtrListIterator<SUIT_Application> anIter (anApplications);
+         SUIT_Application* aFirstApp = anIter.current();
+         while (SUIT_Application* anApp = anIter.current()) {
+           ++anIter;
+           if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+             if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+               MESSAGE("There is an application with active study : " << aStudy->studyName());
+               if (myStudyName == aStudy->studyName()) {
+                 isActive = true;
+                 break;
+               }
+             }
+           }
+         }
+         if (!isActive) {
+           MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!");
+           // Has to be loaded in an empty or in a new application
+           SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
+           anApp->onLoadDoc(myStudyName);
+         }
+       }
+    };
+    
     if (!CORBA::is_nil(theStudy))
     {
       CORBA::String_var aName = theStudy->Name();
@@ -413,29 +446,7 @@ namespace VISU{
       MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'");
       myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
 
-      bool isActive = false;
-      SUIT_Session* aSession = SUIT_Session::session();
-      QPtrList<SUIT_Application> anApplications = aSession->applications();
-      QPtrListIterator<SUIT_Application> anIter (anApplications);
-      SUIT_Application* aFirstApp = anIter.current();
-      while (SUIT_Application* anApp = anIter.current()) {
-       ++anIter;
-       if (SUIT_Study* aSStudy = anApp->activeStudy()) {
-         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
-            MESSAGE("There is an application with active study : " << aStudy->studyName());
-           if (aStudyName == aStudy->studyName()) {
-              isActive = true;
-             break;
-           }
-         }
-       }
-      }
-      if (!isActive) {
-        MESSAGE("!!! anApp->onLoadDoc(aName.in()) !!!");
-        // Has to be loaded in an empty or in a new application
-        SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
-       anApp->onLoadDoc(aName.in());
-      }
+      ProcessVoidEvent(new TEvent(aStudyName)); 
     } else {
       MESSAGE("CORBA::is_nil(theStudy)");
     }