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();
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)");
}