Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI.cxx
index b1cf1a54e098667ade0a36fe1fa7f43c4583b495..feb934f71f4218f105f270e5016ea833a46cfbb8 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -375,43 +375,55 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
     SUPERVGraph_View* view = supervFrame->getViewWidget();
     SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
     if ( aGraph ) {
+      // mkr: PAL12449 --->
+      if ( (( SalomeApp_Study* )(aGraph->getStudy()))->studyDS() && !aGraph->isDataflowInStudy() ) {
+       const int aWarnResult = QMessageBox::information(application()->desktop(), tr("MSG_INFO"),
+                                                        tr("MSG_GRAPH_UNSAVED"),
+                                                        QMessageBox::Yes, QMessageBox::No);
+       if ( aWarnResult == QMessageBox::Yes ) {
+         aGraph->addDataflowToStudy();
+         updateObjBrowser();
+       }
+      }
+      // mkr: PAL12449 <---
+      
       unregisterGraph(aGraph);
       SUPERV_Graph aDataFlow = aGraph->getDataflow();
       if ( !SUPERV_isNull( aDataFlow ) ) {
-        if ( aDataFlow->IsExecuting() ) {
-          const int aMsgResult = QMessageBox::warning(application()->desktop(),
-                                                      tr("WARNING"),
-                                                      tr("MSG_DF_RUNNING"),
-                                                      tr("MSG_DF_EXECUTION"),
-                                                      tr("MSG_DF_KILL"));
-          if ( aMsgResult == 1 ) {
-            // KILL EXECUTION
-            if ( aDataFlow->Kill() ) {
-              // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
-              // while sets myIsActive flag to false when it receives such event/state
-              // after myIsActive is false it calls QThread::exit() to terminate.
-
-              // why while() { qApp->processEvents() } ?
-              // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
-              // method using SALOME_Event paradigm, ProcessVoidEvent() function -
-              // it puts this event to the main application event loop, in which we are being now.
-              // So if we block main GUI application thread (by calling aGraph->getMyThread()->wait() here)
-              // then we will have a deadlock of 2 threads waiting for one another
-              while (aGraph->getMyThread()->running())
-                qApp->processEvents();
-            }
-          }
-          else { // BACKGROUND EXECUTION
-            emit KillMainThread(true); // set SUPERVGUI_Thread::myIsActive to false
-            while ( aGraph->getMyThread()->running() )
-              qApp->processEvents();
-          }
-        }
-        else { // EXECUTION IS FINISHED, JUST DESTROY THE SUPERVGUI_Thread object and return.
-          emit KillMainThread(true);
-          while ( aGraph->getMyThread()->running() )
-            qApp->processEvents();
-        }
+       if ( aDataFlow->IsExecuting() ) {
+         const int aMsgResult = QMessageBox::warning(application()->desktop(),
+                                                     tr("WARNING"),
+                                                     tr("MSG_DF_RUNNING"),
+                                                     tr("MSG_DF_EXECUTION"),
+                                                     tr("MSG_DF_KILL"));
+         if ( aMsgResult == 1 ) {
+           // KILL EXECUTION
+           if ( aDataFlow->Kill() ) {
+             // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
+             // while sets myIsActive flag to false when it receives such event/state
+             // after myIsActive is false it calls QThread::exit() to terminate.
+             
+             // why while() { qApp->processEvents() } ?
+             // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
+             // method using SALOME_Event paradigm, ProcessVoidEvent() function -
+             // it puts this event to the main application event loop, in which we are being now.
+             // So if we block main GUI application thread (by calling aGraph->getMyThread()->wait() here)
+             // then we will have a deadlock of 2 threads waiting for one another
+             while (aGraph->getMyThread()->running())
+               qApp->processEvents();
+           }
+         }
+         else { // BACKGROUND EXECUTION
+           emit KillMainThread(true); // set SUPERVGUI_Thread::myIsActive to false
+           while ( aGraph->getMyThread()->running() )
+             qApp->processEvents();
+         }
+       }
+       else { // EXECUTION IS FINISHED, JUST DESTROY THE SUPERVGUI_Thread object and return.
+         emit KillMainThread(true);
+         while ( aGraph->getMyThread()->running() )
+           qApp->processEvents();
+       }
       }
     }
   }