]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Fix the following cases:
authormkr <mkr@opencascade.com>
Wed, 19 Jan 2005 13:59:36 +0000 (13:59 +0000)
committermkr <mkr@opencascade.com>
Wed, 19 Jan 2005 13:59:36 +0000 (13:59 +0000)
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.

src/SUPERVGUI/SUPERVGUI_Canvas.cxx
src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx
src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx
src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx
src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx
src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx
src/SUPERVGUI/SUPERVGUI_Main.cxx
src/SUPERVGUI/SUPERVGUI_Main.h

index 1a622caa17ce07833503a909442c9de567fb424c..566a761e4340eb0ceceb09c5b5126db30dc6abc3 100644 (file)
@@ -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
index c7ad48573cf60e87c407af55f52ac7eb74ca8641..a95653493a454231bb495130ef33bbcfbc564fc9 100644 (file)
@@ -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
index 239f53a8cab531ad71b5fd8038d807febec0e594..c7a7f65e117f1ea936c8944ab83d78999067f923 100644 (file)
@@ -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 = "<<getTitleWidth()
-//      <<" hT = "<<getTitleHeight()<<endl;
   return QRect((int)x(), (int)y(), getTitleWidth(), getTitleHeight());
 }
 
 QRect SUPERVGUI_CanvasCellNodePrs::getLabelRect() const
 {
-//  MESSAGE("SUPERVGUI_CanvasCellNodePrs::getLabelRect()!!!");
-//  cout<<" xL = "<<((int)x())+getTitleWidth()
-//      <<" yL = "<<(int)y()
-//      <<" wL = "<<getLabelWidth()
-//      <<" hL = "<<getLabelHeight()<<endl;
   return QRect(((int)x())+getTitleWidth(), (int)y(), getLabelWidth(), getLabelHeight());
 }
 
 QRect SUPERVGUI_CanvasCellNodePrs::getStatusRect() const
 {
-//  MESSAGE("SUPERVGUI_CanvasCellNodePrs::getStatusRect()!!!");
-//  cout<<" xS = "<<((int)x())+getTitleWidth()+getLabelWidth()
-//      <<" yS = "<<(int)y()
-//      <<" wS = "<<getStatusWidth()
-//      <<" hS = "<<getStatusHeight()<<endl;
   return QRect(((int)x())+getTitleWidth()+getLabelWidth(), (int)y(),
               getStatusWidth(), getStatusHeight());
 }
@@ -176,13 +152,11 @@ int SUPERVGUI_CanvasCellNodePrs::getStatusWidth() const {
 
 int SUPERVGUI_CanvasCellNodePrs::width() const
 {
-//MESSAGE("SUPERVGUI_CanvasCellNodePrs::width()  begin");
   return myTitleWidth + myLabelWidth + myStatusWidth;
 }
 
 int SUPERVGUI_CanvasCellNodePrs::height() const
 {
-//MESSAGE("SUPERVGUI_CanvasCellNodePrs::height()  begin");
   return getTitleHeight();
 }
 
index be508cac8eb168025787e9d58a1eedb65afdab53..a41424b6a8f0093f9a53581fc14ac535f9b55a07 100644 (file)
@@ -107,6 +107,12 @@ void SUPERVGUI_CanvasStartNode::remove()
     if ( QString(getEngine()->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) 
index e18aacaee1f38079795d5a4a6bdd8923f96ee737..bd8602ae2a86de7478326e827b94277c233534a2 100644 (file)
@@ -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();
index 3c0dd0cb3a3670159dca0f765c7c95b10b4dc280..8ea4956995df957e73d34c8691586e6882b647ff 100644 (file)
@@ -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
index c3c1fb44d0554c6de6ca7eafc8dfa42b31396425..0efe33ad38bc30174dd181a466150c46748ef625 100644 (file)
@@ -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()
index 03f240f2d7d1e1fc080293fac866cada10217458..4009f82beadf77d76ebdf759f991cba78c1acf90 100644 (file)
@@ -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);