From 3f6f0841df1a2c7c868c947bb373a14ab654a2ef Mon Sep 17 00:00:00 2001 From: asv Date: Wed, 26 Jan 2005 13:38:37 +0000 Subject: [PATCH] Fix for PAL7164: after analysis of the bug, it was found out that PublishInStudy() in GEOM was called twice from Supervisor. It was done from CanvasPort::sync() function. Since sync() is an asinchronious function, it is called when a signal comes, and in other occasions, it was decided to move the put_in_study functionality to another place - to execute() function of Main, which handles events coming from Engine. If an event is "Node has successfully finished execution", then its CanvasOutPorts are analized, and if some port has "myIsInStudy" flag - then value of this port is put into study. It fixes the bug, since execute() is called exactly once on every event (controlled by Supervisor Engine). --- src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx | 9 ++++++++- src/SUPERVGUI/SUPERVGUI_Main.cxx | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx index 198c5ed..756bd00 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx @@ -80,7 +80,7 @@ QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) && !myPort->Node()->IsMacro()) popup->insertItem(tr("ITM_COPY_PORT"), this, SLOT(copy())); -//int anItem = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + /*int anItem = */popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); // if (getEngine()->IsLinked()) // popup->setItemEnabled(anItem, getEngine()->State() == SUPERV_Ready); // else @@ -272,10 +272,17 @@ QPopupMenu* SUPERVGUI_CanvasPortOut::getPopupMenu(QWidget* theParent) void SUPERVGUI_CanvasPortOut::sync() { + /* asv : 26.01.05 : Bug PAL7164 : sometimes CanvasPortOut::sync() is called twice (or maybe even more) + by mistake. It happens because of incorrect Qt events, or other reason, but it is not a + stable feature (bug). Adding an object in the study in sync() is therefore called more than once + which is a BUG. I decided to move call to putDataStudy() method to Event handling function. + When a node successfully finishes execution - check the ports and put out-value to study, + if the corresponding flag is set. bool ok = getEngine()->State() == SUPERV_Ready; if (ok && myInStudy) { myInStudy = getMain()->putDataStudy(getEngine(), STUDY_PORT_OUT); } + */ SUPERVGUI_CanvasPort::update(); } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 0efe33a..667670f 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -49,6 +49,7 @@ using namespace std; #include "SUPERVGUI_Notification.h" #include "SUPERVGUI_Information.h" #include "SUPERVGUI_CanvasControlNode.h" +#include "SUPERVGUI_CanvasPort.h" #include #include @@ -228,7 +229,7 @@ void SUPERVGUI_Main::syncAsync() { /** * Called by thread when dataflow is executing */ -void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) { +void SUPERVGUI_Main::execute( char * theNodeName, SUPERV::GraphState theNodeState ) { if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode"); if ( aNode ) { @@ -239,6 +240,29 @@ void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeStat SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode"); if (aNode) aNode->sync(); } + + // asv : 26.01.05 : Bug PAL7164 : puting out-value to study if the "put_to_Study" flag is set on a + // CanvasPort the functionality was moved from SUPERVGUI_CanvasPortOut::sync() method please, see + // comment in that method for details. + if ( theNodeState == SUPERV::DoneState ) { + SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode"); + if ( aNode ) { + //cout << " *** theNode " << theNodeName << " received DONE_STATE *** " << endl; + SUPERVGUI_CanvasPortOut* aPortOut; + QObjectList* aPortList = aNode->queryList("SUPERVGUI_CanvasPortOut"); + QObjectListIt aPortIt(*aPortList); + while ((aPortOut=(SUPERVGUI_CanvasPortOut*)aPortIt.current()) != 0) { + ++aPortIt; + if ( aPortOut->isInStudy() && aPortOut->getEngine()->State() == SUPERV::ReadyState ) { + //cout << " *** " << theNodeName << "[" << aPortOut->name() << "]--> goes into study *** " << endl; + putDataStudy( aPortOut->getEngine(), STUDY_PORT_OUT ); + } + } + delete aPortList; + } + //else //normal case if Node is not found is when node is a graph! it can receive DoneState as well! + // MESSAGE( "ERROR in SUPERVGUI_Main::execute() : CanvasNode \"" << theNodeName << "\" NOT FOUND in myCanvas" ); + } } -- 2.39.2