From d6dfb1036394a951beac9471780cd195b9cb7038 Mon Sep 17 00:00:00 2001 From: mkr Date: Mon, 29 May 2006 08:06:22 +0000 Subject: [PATCH] Fix for bug PAL12449: No warning is displayed when the graph view is closed. --- src/SUPERVGUI/SUPERVGUI.cxx | 80 +++++++++++++++++++--------------- src/SUPERVGUI/SUPERV_msg_en.po | 3 ++ 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index b1cf1a5..743e9c1 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -375,43 +375,55 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) { SUPERVGraph_View* view = supervFrame->getViewWidget(); SUPERVGUI_Main* aGraph = dynamic_cast(view); if ( aGraph ) { + // mkr: PAL12449 ---> + if ( !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(); + } } } } diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 785d577..bc59802 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -244,6 +244,9 @@ msgstr "Choose a Data in Study" msgid "MSG_GRAPH_DISPLAYED" msgstr "The DataFlow %1 \nis already displayed. Open again?" +msgid "MSG_GRAPH_UNSAVED" +msgstr "This dataflow has not been saved in study. Do you want to add it in study before close?" + #:SUPERVGUI_Main.cxx:288 msgid "MSG_CRL_NOTCOMPLETE" msgstr "Link Creation Is Not Complete" -- 2.39.2