From a2770422e6265388006b1f0a9757af0e5cffb5dc Mon Sep 17 00:00:00 2001 From: asv Date: Mon, 7 Feb 2005 11:38:07 +0000 Subject: [PATCH] Fix for PAL8027. from bugzilla: The following program behaviour was implemented for "Add node", "Insert file", "Paste node" operations: if the dataflow is being executed - user is asked to Kill the execution before operation or cancel the operation. changes in the code: SUPERVGUI_Main::ReadyToModify() operation was introduced to handle checking and killing of execution. --- src/SUPERVGUI/SUPERVGUI_Clipboard.cxx | 3 ++ src/SUPERVGUI/SUPERVGUI_Main.cxx | 74 ++++++++++++++++----------- src/SUPERVGUI/SUPERVGUI_Main.h | 3 ++ 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx b/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx index a9d4637..a26faf8 100644 --- a/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx @@ -139,6 +139,9 @@ void SUPERVGUI_Clipboard::pasteNode() { SUPERVGUI_Main* aMain = Supervision.getMain(); if ( !CORBA::is_nil( aNode ) && aMain ) { + if ( !aMain->ReadyToModify() ) // null dataflow or executing, .. + return; + aMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> PAL7960 SUPERV::Graph_var dataflow = aMain->getDataflow(); diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index d69ac8f..33e2a18 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -332,31 +332,33 @@ void SUPERVGUI_Main::showCanvas() { } void SUPERVGUI_Main::insertFile() { - Trace("SUPERVGUI_Main::insertFile"); - if ((SUPERV_isNull(dataflow))) return; + Trace("SUPERVGUI_Main::insertFile"); + + if ( !ReadyToModify() ) // null dataflow or executing, .. + return; - QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - "", - "*.xml", - tr("MSG_GRAPH_INSERT"), - true); - if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name + QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + "", + "*.xml", + tr("MSG_GRAPH_INSERT"), + true); + if ( !f.isEmpty() ) { // not Cancel, but "OK" was pressed with valid file name - Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960 + Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> see 7960 - if (dataflow->Import(f.latin1())) { - if (myCurrentView == CANVASTABLE) { - myArray->destroy(); - myArray->create(); - } - else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { - myCanvas->merge(); - } - sync(); - } else { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + if (dataflow->Import(f.latin1())) { + if (myCurrentView == CANVASTABLE) { + myArray->destroy(); + myArray->create(); + } + else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { + myCanvas->merge(); } + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); } + } } void SUPERVGUI_Main::copy() { @@ -595,18 +597,9 @@ void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le */ void SUPERVGUI_Main::addNode() { Trace("SUPERVGUI_Main::addNode"); - bool error = SUPERV_isNull( dataflow ); - if ( error ) + + if ( !ReadyToModify() ) // null dataflow or executing, .. return; - - if ( dataflow->IsExecuting() ) { - error = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No - tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_NO" ), 0, 1, 0 ); - if ( error ) // user selected NOT to kill dataflow and NOT to add new node - return; - else // user selected to kill the dataflow and add new node after that - kill(); - } //Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, commented: PAL7960 Supervision.getBrowser()->choose(); @@ -1199,6 +1192,25 @@ void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode) } } +/** + * ReadyToModify() must be called before any modification + * operation - asks to kill execution of dataflow. If returns false - + * modification (==Editing() ) is not allowed. + */ +bool SUPERVGUI_Main::ReadyToModify() { + if ( CORBA::is_nil( dataflow ) ) + return false; + if ( dataflow->IsExecuting() ) { + bool quit = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No + tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_CANCEL" ), 0, 1, 0 ); + if ( quit ) // user selected NOT to kill dataflow and NOT to add new node + return false; + else if ( dataflow->IsExecuting() ) // user selected to kill the dataflow and add new node after that + kill(); // checking again for IsExecuting to be sure that it was not finished while MB was up + } + return true; +} + /******************************* SUPERVGUI_Thread class ****************************************/ SUPERVGUI_Thread::SUPERVGUI_Thread() :QThread() diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 9321579..274a179 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -124,6 +124,9 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void Editing(); // any Editing operation is to be performed -> // activate Editors data model in Engine + bool ReadyToModify(); // must be called before any modification + // operation - asks to kill execution of dataflow. If returns false - + // modification (==Editing() ) is not allowed. void removeArrayChild(SUPERV::CNode_ptr theNode); -- 2.39.2