From a7428eb65acd2f180cd889b3e30b221860ee9236 Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 17 Feb 2006 15:01:07 +0000 Subject: [PATCH] Fix for PAL8150 : CRASH after "Put in Study" applied to the "readMeshInFile" node. --- src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx | 8 +++ src/SUPERVGUI/SUPERVGUI_CanvasPort.h | 3 + src/SUPERVGUI/SUPERVGUI_Main.cxx | 95 ++++++++++++++++++++++++++ src/SUPERVGUI/SUPERVGUI_Main.h | 8 ++- 4 files changed, 113 insertions(+), 1 deletion(-) diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx index 2b8b0f5..b690092 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx @@ -259,6 +259,9 @@ SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut(QObject* theParent, SUPERVGUI_M { Trace("SUPERVGUI_CanvasPortOut::SUPERVGUI_CanvasPortOut"); myInStudy = false; + + // mkr : PAL8150 + connect(this, SIGNAL(putInStudy( QString* )), getMain(), SLOT(onPutInStudy( QString* ))); } SUPERVGUI_CanvasPortOut::~SUPERVGUI_CanvasPortOut() @@ -321,6 +324,11 @@ void SUPERVGUI_CanvasPortOut::toStudy() aSupMod->unregisterGraph(getMain()); aSupMod->registerGraph(getMain()->getDataflow()->getIOR(), getMain()); } + + // mkr : PAL8150 + QString aNodePortName = QString( getEngine()->Node()->Name() ) + QString( "_" ) + QString( getEngine()->Name() ); + emit putInStudy( &aNodePortName ); + } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h index 6ed5f5d..e218d57 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h @@ -97,6 +97,9 @@ class SUPERVGUI_CanvasPortOut : public SUPERVGUI_CanvasPort { virtual QPopupMenu* getPopupMenu(QWidget* theParent); + signals: + void putInStudy( QString* ); // mkr : PAL8150 + public slots: void toStudy(); diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 8b5ceba..4aa33b0 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -65,6 +65,20 @@ #include using namespace boost; +// mkr : PAL8150 +#define SYNCPUTINSTUDY(NodesName) \ + for ( int n = 0; n < nodes->NodesName.length(); n++ ) { \ + SUPERV_CNode aCNode = SUPERV::CNode::_narrow(nodes->NodesName[n]); \ + SUPERV_Ports aPortList = aCNode->Ports(); \ + for (int p = 0; p < aPortList->length(); p++) { \ + SUPERV::Port_ptr aPort = aPortList[p].in(); \ + if ( !aPort->IsInput() && !aPort->IsGate() ) { \ + bool aInStudy = dynamic_cast( aMain->getCanvas()->getPort(aPort) )->isInStudy(); \ + dynamic_cast( getCanvas()->getPort( getDataflow()->Node(aCNode->Name())->Port(aPort->Name()) ) )->setStudyState(aInStudy); \ + } \ + } \ + } + SUPERVGUI_Main::SUPERVGUI_Main( SUPERVGraph_ViewFrame* theParent, SUIT_Desktop* theDesktop, SUPERV_Graph theDataFlow ) : SUPERVGraph_View(theParent), @@ -88,6 +102,9 @@ SUPERVGUI_Main::SUPERVGUI_Main( SUPERVGraph_ViewFrame* theParent, } else { init(theDesktop); } + + syncPutInStudy(); // mkr : PAL8150 + // mkr : IPAL11362 connect(this, SIGNAL(EventToSync()), this, SLOT(onObjectCreatedDeleted())); } @@ -605,6 +622,84 @@ void SUPERVGUI_Main::onObjectCreatedDeleted() } } +// mkr : PAL8150 : synchronize many views of the same dataflow ("Put In Study"/"Not In Study" operation) +void SUPERVGUI_Main::onPutInStudy( QString* theNodePortName ) +{ + if ( study ) { + if ( STD_Application* app = dynamic_cast( study->application() ) ) { + ViewManagerList aVMList; + app->viewManagers( SUPERVGraph_Viewer::Type(), aVMList ); + SUIT_ViewManager* aVM; + for ( aVM = aVMList.first(); aVM; aVM = aVMList.next() ) { + QPtrVector aVWList = aVM->getViews(); + for ( int i = 0; i < aVWList.count(); i++ ) { + SUPERVGraph_ViewFrame* aVW = dynamic_cast( aVWList[i] ); + QObjectList* aMainList = aVW->queryList("SUPERVGUI_Main"); + if ( aMainList->count() == 1 ) { + SUPERVGUI_Main* aMain = dynamic_cast( aMainList->first() ); + if ( aMain ) + if ( !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR()) // equal dataflows + && + aMain != this ) { // not equal mains + QString aNodeName = theNodePortName->left( theNodePortName->find('_') ); + QString aPortName = theNodePortName->right( theNodePortName->length() - theNodePortName->find('_') - 1 ); + bool anIsInStudy = dynamic_cast( getCanvas()->getPort( getDataflow()->Node( aNodeName )->GetOutPort( aPortName ) ) )->isInStudy(); + dynamic_cast( aMain->getCanvas()->getPort( aMain->getDataflow()->Node( aNodeName )->GetOutPort( aPortName ) ) )->setStudyState( anIsInStudy ); + } + } + } + } + } + } +} + +// mkr : PAL8150 : synchronize many views of the same dataflow ("Display" operation for dataflow) +void SUPERVGUI_Main::syncPutInStudy() +{ + if ( study ) { + if ( STD_Application* app = dynamic_cast( study->application() ) ) { + ViewManagerList aVMList; + app->viewManagers( SUPERVGraph_Viewer::Type(), aVMList ); + SUIT_ViewManager* aVM; + for ( aVM = aVMList.first(); aVM; aVM = aVMList.next() ) { + QPtrVector aVWList = aVM->getViews(); + for ( int i = 0; i < aVWList.count(); i++ ) { + SUPERVGraph_ViewFrame* aVW = dynamic_cast( aVWList[i] ); + QObjectList* aMainList = aVW->queryList("SUPERVGUI_Main"); + if ( aMainList->count() == 1 ) { + SUPERVGUI_Main* aMain = dynamic_cast( aMainList->first() ); + if ( aMain ) + if ( !CORBA::is_nil( aMain->getDataflow() ) + && + !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR()) // equal dataflows + && + aMain != this ) { // not equal mains + + // check "myInStudy" field of output ports of original main (i.e. this main) + // and synchronize this property for nodes' output ports of dublicate main (i.e. of aMain) + SUPERV_Nodes nodes = aMain->getDataflow()->Nodes(); + + SYNCPUTINSTUDY(CNodes); + SYNCPUTINSTUDY(FNodes); + SYNCPUTINSTUDY(INodes); + SYNCPUTINSTUDY(GNodes); + SYNCPUTINSTUDY(LNodes); + SYNCPUTINSTUDY(ELNodes); + SYNCPUTINSTUDY(SNodes); + SYNCPUTINSTUDY(ESNodes); + SYNCPUTINSTUDY(Graphs); + + setRunTime( aMain->getRunTime() ); + + break; + } + } + } + } + } + } +} + void SUPERVGUI_Main::run( const bool andSuspend ) { Trace("SUPERVGUI_Main::run"); if ( SUPERV_isNull(dataflow) ) diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index cd5496a..a6a6ac8 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -136,6 +136,10 @@ class SUPERVGUI_Main: public SUPERVGraph_View { virtual void resizeView( QResizeEvent* theEvent ); + // mkr : PAL8150 + void setRunTime( QDateTime theRunTime ) { myRunTime = theRunTime; } + QDateTime getRunTime() const { return myRunTime; } + signals: void KillMyThread(bool theValue); void EventToSync(); // mkr : IPAL11362 @@ -162,6 +166,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void onShowToolbar(); void onObjectCreatedDeleted(); // mkr : PAL8237 + void onPutInStudy( QString* ); // mkr : PAL8150 private slots: void chooseData(QListViewItem* item); @@ -172,7 +177,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void syncNotification(); bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp); void closeEvent(QCloseEvent*); - + void syncPutInStudy(); // mkr : PAL8150 + SUPERV_Graph dataflow; QMap mySubGraphs; -- 2.39.2