+ SUPERV_Graph aDataFlow = aGraph->getDataflow();
+ if ( !SUPERV_isNull( aDataFlow ) ) {
+ if ( aDataFlow->IsExecuting() ) {
+ const int aMsgResult = QMessageBox::warning(QAD_Application::getDesktop(),
+ 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();
+ }
+ }