From: mkr Date: Wed, 19 Jan 2005 13:59:36 +0000 (+0000) Subject: Fix the following cases: X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=32c4fff0bb048ad88514df09596363812c513d72;p=modules%2Fsuperv.git Fix the following cases: 1) closing dataflow window in Table view leads to exception, 2) node's deletion in Full view and then switching to Table view leads to exception, 3) remove unnecessary COUTs and MESSAGEs. --- diff --git a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx index 1a622ca..566a761 100644 --- a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx @@ -105,6 +105,7 @@ SUPERVGUI_Canvas::~SUPERVGUI_Canvas() { QObject* anObj; while ( (anObj = aIt.current()) != 0 ) { ++aIt; + aNodeList->removeRef(anObj); delete anObj; } // asv : list returned by queryList() must be removed diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx index c7ad485..a956534 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx @@ -160,8 +160,6 @@ bool SUPERVGUI_CanvasArray::create() { // there is no any calculations if (ncols == 0) return false; - QCanvasItemList anIL1 = this->allItems(); - QPen pen(Qt::SolidLine); pen.setWidth(1); QBrush br(MAIN_TITLE); @@ -207,8 +205,6 @@ bool SUPERVGUI_CanvasArray::create() { myOldThreadNum = ncols; - QCanvasItemList anIL2 = this->allItems(); - y = 60; bool LevelHasDiffNT = false; for (int li = 0; li <= nligs; li++) { @@ -222,9 +218,6 @@ bool SUPERVGUI_CanvasArray::create() { } if (nodes->FNodes.length() != 0 ) { ADDNODES(FNodes,LevelHasDiffNT); - - QCanvasItemList anIL3 = this->allItems(); - if (aSumNum > nodes->FNodes.length()) LevelHasDiffNT = true; } @@ -255,8 +248,6 @@ bool SUPERVGUI_CanvasArray::create() { nodeX = 50; nodeY = y + CELL_HEIGHT*2; - QCanvasItemList anIL4 = this->allItems(); - return true; } @@ -264,9 +255,6 @@ bool SUPERVGUI_CanvasArray::create() { void SUPERVGUI_CanvasArray::destroy() { Trace("SUPERVGUI_Array::destroy"); - QCanvasItemList anIL1 = this->allItems(); - const QObjectList* anCL1 = this->children(); - QObjectList* aCellList = queryList("SUPERVGUI_CanvasCellNode"); QObjectListIt aIt(*aCellList); QObject* anObj; @@ -307,7 +295,6 @@ void SUPERVGUI_CanvasArray::destroy() { delete aTextList; - QCanvasItemList anIL2 = this->allItems(); } SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::getCellNode(SUPERV::CNode_ptr theNode) const diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx index 239f53a..c7a7f65 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx @@ -21,7 +21,6 @@ SUPERVGUI_CanvasCellNodePrs::SUPERVGUI_CanvasCellNodePrs(QCanvas* theCanvas, SUP SUPERVGUI_CanvasNodePrs(theCanvas, theNode, true) { myPortVisible = false; - QCanvasItemList anIL2 = canvas()->allItems(); } SUPERVGUI_CanvasCellNodePrs::~SUPERVGUI_CanvasCellNodePrs() @@ -43,12 +42,10 @@ void SUPERVGUI_CanvasCellNodePrs::moveBy(double dx, double dy) { } void SUPERVGUI_CanvasCellNodePrs::drawShape(QPainter& thePainter) { -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawShape begin"); drawTitle(thePainter); drawLabel(thePainter); drawStatus(thePainter); drawFrame(thePainter); -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawShape end"); } void drawCellText(QPainter& thePainter, const QString& theText, @@ -84,7 +81,6 @@ void drawCellText(QPainter& thePainter, const QString& theText, } void SUPERVGUI_CanvasCellNodePrs::drawTitle(QPainter& thePainter) { -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawTitle begin"); QBrush saved = thePainter.brush(); if (getNode()->getEngine()->IsLoop() || getNode()->getEngine()->IsEndLoop() || @@ -100,12 +96,10 @@ void SUPERVGUI_CanvasCellNodePrs::drawTitle(QPainter& thePainter) { thePainter.setBrush(saved); drawCellText(thePainter, getNode()->getEngine()->Name(), getTitleRect(), Qt::AlignLeft); -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawTitle end"); } void SUPERVGUI_CanvasCellNodePrs::drawLabel(QPainter& thePainter) { -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawLabel begin"); QRect r = getLabelRect(); QPen saved = thePainter.pen(); @@ -114,12 +108,10 @@ void SUPERVGUI_CanvasCellNodePrs::drawLabel(QPainter& thePainter) thePainter.setPen(saved); drawCellText(thePainter, getNode()->getLabelText(), r, Qt::AlignLeft); -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawLabel end"); } void SUPERVGUI_CanvasCellNodePrs::drawStatus(QPainter& thePainter) { -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawStatus begin"); QRect r = getStatusRect(); QBrush savedB = thePainter.brush(); @@ -128,36 +120,20 @@ void SUPERVGUI_CanvasCellNodePrs::drawStatus(QPainter& thePainter) thePainter.setBrush(savedB); drawCellText(thePainter, getStatus(), r, Qt::AlignHCenter); -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::drawStatus end"); } QRect SUPERVGUI_CanvasCellNodePrs::getTitleRect() const { -//MESSAGE("SUPERVGUI_CanvasCellNodePrs::getTitleRect()!!!"); -// cout<<" xT = "<<(int)x() -// <<" yT = "<<(int)y() -// <<" wT = "<Name()) == QString(aCB->getCopyNode()->Name()) ) aCB->setCopyNode( 0 ); + // mkr: since the deletion of the node allow only in CANVAS view, + // it is necessary to remove the CanvasArray's children, which + // have the same CNode engine as deleting node + getMain()->removeArrayChild(getEngine()); + getMain()->removeArrayChild(myCoupled->getEngine()); + getEngine()->destroy(); if (myCoupled) diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx index e18aaca..bd8602a 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx @@ -56,27 +56,29 @@ SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* t myLabelText = aNewComment; - // create node ports - isIgnore = true; - SUPERV_Ports aPortList = myNode->Ports(); - for (int i = 0; i < aPortList->length(); i++) { - createPort(aPortList[i].in()); - } - - SUPERV_StreamPorts aStreamPortList = myNode->StreamPorts(); - for (int i = 0; i < aStreamPortList->length(); i++) { - createStreamPort(aStreamPortList[i].in()); + // mkr : if the SUPERVGUI_CavasCellNode created (for CANVASTABLE view), + // we haven't create its ports + if (!theIsCell) { + // create node ports + isIgnore = true; + SUPERV_Ports aPortList = myNode->Ports(); + for (int i = 0; i < aPortList->length(); i++) + createPort(aPortList[i].in()); + + SUPERV_StreamPorts aStreamPortList = myNode->StreamPorts(); + for (int i = 0; i < aStreamPortList->length(); i++) { + createStreamPort(aStreamPortList[i].in()); + } } isIgnore = false; - - QCanvasItemList anIL2 = ((QCanvas*)parent())->allItems(); } SUPERVGUI_CanvasNode::~SUPERVGUI_CanvasNode() { isIgnore = true; if ( myPrs ) { + myPrs->hide(); delete myPrs; myPrs = 0; } @@ -348,6 +350,7 @@ void SUPERVGUI_CanvasNode::rename() { } void SUPERVGUI_CanvasNode::remove() { + Trace("SUPERVGUI_CanvasNode::remove"); myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag //set myCopyPort from Main object to empty if engine of this port is deleted @@ -362,8 +365,12 @@ void SUPERVGUI_CanvasNode::remove() { if ( aCB->isCopyNode() ) if ( QString(myNode->Name()) == QString(aCB->getCopyNode()->Name()) ) aCB->setCopyNode( 0 ); - - Trace("SUPERVGUI_CanvasNode::remove"); + + // mkr: since the deletion of the node allow only in CANVAS view, + // it is necessary to remove the CanvasArray's children, which + // have the same CNode engine as deleting node + myMain->removeArrayChild(myNode); + SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); setDestroyed(); myNode->destroy(); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx index 3c0dd0c..8ea4956 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx @@ -61,14 +61,11 @@ SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, setState(myNode->getEngine()->State()); updatePorts(); } - - QCanvasItemList anIL2 = canvas()->allItems(); } SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs() { - MESSAGE("SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs"); if ( !myCellPrs ) { if ( myPointIn ) { delete myPointIn; @@ -79,7 +76,6 @@ SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs() myPointOut = 0; } } - hide(); } int SUPERVGUI_CanvasNodePrs::rtti() const diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index c3c1fb4..0efe33a 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -141,6 +141,7 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { myCanvas->merge(); } + sync(); show(); if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) { @@ -1190,6 +1191,26 @@ void SUPERVGUI_Main::Editing() { sync(); } +void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode) +{ + // mkr: since the deletion of the node allow only in CANVAS view, + // it is necessary to remove the CanvasArray's children, which + // have the same CNode engine as deleting node. This CNode is given + // as argument + if (myArray) { + const QObjectList* aChList = myArray->children(); + QObjectListIt aItChList(*aChList); + SUPERVGUI_CanvasNode* anObjNode; + while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) { + ++aItChList; + if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) { + myArray->removeChild(anObjNode); + delete anObjNode; + } + } + } +} + /******************************* SUPERVGUI_Thread class ****************************************/ SUPERVGUI_Thread::SUPERVGUI_Thread() :QThread() diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 03f240f..4009f82 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -131,6 +131,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void Editing(); // any Editing operation is to be performed -> // activate Editors data model in Engine + void removeArrayChild(SUPERV::CNode_ptr theNode); + signals: void KillMyThread(bool theValue);