]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Fix for bug PAL8237 : Crash after trying to activate dataflow window.
authormkr <mkr@opencascade.com>
Tue, 24 Jan 2006 14:20:17 +0000 (14:20 +0000)
committermkr <mkr@opencascade.com>
Tue, 24 Jan 2006 14:20:17 +0000 (14:20 +0000)
src/SUPERVGUI/SUPERVGUI.cxx
src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx
src/SUPERVGUI/SUPERVGUI_CanvasLink.h
src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx
src/SUPERVGUI/SUPERVGUI_CanvasNode.h
src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx
src/SUPERVGUI/SUPERVGUI_CanvasPort.h
src/SUPERVGUI/SUPERVGUI_CanvasView.cxx
src/SUPERVGUI/SUPERVGUI_CanvasView.h
src/SUPERVGUI/SUPERVGUI_Main.cxx
src/SUPERVGUI/SUPERVGUI_Main.h

index ab180c7ff7c1232aecc51e4e26c052275729473e..4f75dfb09c80fcfbc246399f16d9127643861bfb 100644 (file)
@@ -487,6 +487,8 @@ void SUPERVGUI::displayDataflow() {
     else {
       // second case : get empty initial view frame as new ViewFrame object
       aViewFrame = myInitialViewFrame;
+      // mkr : PAL8237 : remove first "gag" Main from children
+      aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
     }
 
     if( aViewFrame ) {
@@ -676,6 +678,8 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
   else {
     // 2. get empty initial view frame as new ViewFrame object
     aViewFrame = myInitialViewFrame;
+    // mkr : PAL8237 : remove first "gag" Main from children
+    aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
   }
 
   if ( aViewFrame ) {
index ef49cd88f91c36b79d09b360b8554f5878ab7804..a58cbb5458bbad5f78a65a9917650c3045305c0d 100644 (file)
@@ -51,6 +51,9 @@ SUPERVGUI_CanvasLink::SUPERVGUI_CanvasLink(QObject* theParent, SUPERVGUI_Main* t
     else
       myColor = DRAW_COLOR;
   }
+
+  // mkr : PAL8237
+  connect(this, SIGNAL(objectCreatedDeleted()), myMain, SLOT(onObjectCreatedDeleted()));
 }
 
 SUPERVGUI_CanvasLink::~SUPERVGUI_CanvasLink()
@@ -230,7 +233,10 @@ void SUPERVGUI_CanvasLink::remove() {
       }
     }
     myLink->destroy();
+
+    emit objectCreatedDeleted(); // mkr : PAL8237
   }
+
   delete this;
   if (aPort && !aValue.isEmpty() && myMain->getDataflow()->GraphLevel() == 0) {
     aPort->setValue(aValue);
@@ -253,8 +259,10 @@ void SUPERVGUI_CanvasLink::addPoint() {
       anIndex = aPoint->getIndex()+1;
       if (anIndex < 1) anIndex = 1;
     }
-    if (myLink && !SUPERV_isNull(myLink)) 
+    if (myLink && !SUPERV_isNull(myLink)) {
       myLink->AddCoord(anIndex, mySelectedPoint.x(), mySelectedPoint.y());
+      emit objectCreatedDeleted(); // mkr : PAL8237
+    }
     merge();
     myMain->getCanvas()->update();
   }
@@ -263,8 +271,10 @@ void SUPERVGUI_CanvasLink::addPoint() {
 void SUPERVGUI_CanvasLink::removePoint() {
   if (mySelectedItem && mySelectedItem->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) {
     SUPERVGUI_CanvasPointPrs* aPoint = (SUPERVGUI_CanvasPointPrs*) mySelectedItem;
-    if (myLink && !SUPERV_isNull(myLink)) 
+    if (myLink && !SUPERV_isNull(myLink)) {
       myLink->RemoveCoord(aPoint->getIndex());
+      emit objectCreatedDeleted(); // mkr : PAL8237
+    }
     merge();
     myMain->getCanvas()->update();
   }
index 4f620fbf963b3d7f5c2822832e973faf9d509f12..f9592afda818ffd4aee735b822f74522f54eaadb 100644 (file)
@@ -43,6 +43,9 @@ class SUPERVGUI_CanvasLink : public QObject {
 
     QString getToolTipText() const;
 
+  signals:
+    void objectCreatedDeleted(); // mkr : PAL8237
+
   public slots:
     virtual void remove();
     void addPoint();
index 81183a0d449cc4cfb4017fa09352248c94d2fd97..cd3a9550bc30c42b221f7c45cc84ff3172342fb0 100644 (file)
@@ -76,6 +76,10 @@ SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode( SUIT_ResourceMgr* mgr, QObject* theP
   }
 
   isIgnore = false;
+
+  // mkr : PAL8237
+  connect(this, SIGNAL(objectCreatedDeleted()), myMain, SLOT(onObjectCreatedDeleted()));
+  emit objectCreatedDeleted();
 }
 
 SUPERVGUI_CanvasNode::~SUPERVGUI_CanvasNode()
@@ -126,6 +130,8 @@ void SUPERVGUI_CanvasNode::createPort(SUPERV::Port_ptr thePort)
   if (aPort) {
     connect(aPort, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
     if (!isIgnore) getPrs()->updatePorts();
+    
+    emit objectCreatedDeleted(); // mkr : PAL8237
   }
 }
 
@@ -393,6 +399,9 @@ void SUPERVGUI_CanvasNode::remove() {
   SUPERVGUI_Canvas* aCanvas = myMain->getCanvas();
   setDestroyed();
   myNode->destroy();
+
+  emit objectCreatedDeleted(); // mkr : PAL8237
+  
   delete this;
   aCanvas->update();
 }
index 3150466dcca000925ad9f587d0fd6f6ff95496de..d34a65490f0a2ef961fb90fdc89cc1cc5143a3f3 100644 (file)
@@ -73,6 +73,9 @@ class SUPERVGUI_CanvasNode : public QObject {
 
     virtual QString getToolTipText() const;
 
+  signals:
+    void objectCreatedDeleted(); // mkr : PAL8237
+
   public slots:
     void suspendResume();
     void kill();
@@ -102,7 +105,7 @@ class SUPERVGUI_CanvasNode : public QObject {
     virtual void pastePort();
     void managePorts();
     void exportToLib();
-
+  
   protected:
     // redefined by most of CanvasNode successors
     virtual SUPERVGUI_CanvasNodePrs* createPrs() const;
index 45adafe585f519dbf1c4ba23b35bda0adbd71231..2b8b0f51add8e481827c7cc3b0601cd3c4e080d5 100644 (file)
@@ -28,6 +28,9 @@ SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort(QObject* theParent, SUPERVGUI_Main* t
 
   // setName(myPort->Name());
   setName(myMain->getCanvas()->getPortName(thePort));
+
+  // mkr : PAL8237
+  connect(this, SIGNAL(objectDeleted()), myMain, SLOT(onObjectCreatedDeleted()));
 }
 
 SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort()
@@ -137,6 +140,9 @@ void SUPERVGUI_CanvasPort::remove() {
 
   Trace("SUPERVGUI_CanvasPort::remove");
   myPort->destroy();
+  
+  emit objectDeleted(); // mkr : PAL8237
+
   delete this;
 }
 
index fd528139827d215b1b86c688caacb5427f0e4c22..6ed5f5dc0af3a246654e4f914fe0b4a83453858c 100644 (file)
@@ -41,6 +41,9 @@ class SUPERVGUI_CanvasPort : public QObject {
     void removeLink(SUPERVGUI_CanvasLink* theLink);
     void updateLinks();
 
+  signals:
+    void objectDeleted(); // mkr : PAL8237
+
   public slots:
     void sketchLink();
     virtual void remove();
index 94f77c2730db254a5f00a17ba3ef3a065e0ddbd5..f2b54a7bb360728b6d53d5c3303afd59ec2b1aef 100644 (file)
@@ -160,6 +160,9 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU
     myPopup->insertSeparator();
     myShowToolBarItem = myPopup->insertItem( tr( "MEN_SHOW_TOOLBAR" ), myMain, SLOT( onShowToolbar() ) );
   }
+
+  // mkr : PAL8237
+  connect(this, SIGNAL(objectCreated()), myMain, SLOT(onObjectCreatedDeleted()));
 }
  
 
@@ -681,6 +684,8 @@ void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort)
     SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(canvas(), myMain, aLinkEngine);
     aLink->show();
 
+    emit objectCreated(); // mkr : PAL8237
+
     canvas()->update();
     myIsLinkCreating = false;
 
index feda50168b02caa0a792882d6c5e5b13fb81c06d..082a6c7f4e4b262ced20870a2fdeffabbd512d91 100644 (file)
@@ -37,6 +37,9 @@ class SUPERVGUI_CanvasView: public QCanvasView {
     bool isAnyLinkCreating() const { return myIsLinkCreating; }
     void startSketch(SUPERVGUI_CanvasPort* thePort);
 
+  signals:
+    void objectCreated(); // mkr : PAL8237
+
   public slots:
     void addToStudy();
     void onTimeout();
index 13a8e69305d2eb357457204c6e5d7ea01173033f..b48d726f4c2715ae9a0371f87e9fc46a94017422 100644 (file)
@@ -32,6 +32,7 @@
 #include "NOTIFICATION.hxx"
 #include "SALOME_Event.hxx"
 #include "SUPERVGraph_ViewFrame.h"
+#include "SUPERVGraph_ViewModel.h"
 
 #include "LogWindow.h"
 #include "OB_Browser.h"
@@ -556,6 +557,33 @@ void SUPERVGUI_Main::onShowToolbar()
     aVF->getToolBar()->show();
 }
 
+// mkr : PAL8237 : synchronize many views of the same dataflow
+void SUPERVGUI_Main::onObjectCreatedDeleted()
+{
+  if ( study ) {
+    if ( STD_Application* app = dynamic_cast<STD_Application*>( study->application() ) ) {
+      ViewManagerList aVMList;
+      app->viewManagers( SUPERVGraph_Viewer::Type(), aVMList );
+      SUIT_ViewManager* aVM;
+      for ( aVM = aVMList.first(); aVM; aVM = aVMList.next() ) {
+       QPtrVector<SUIT_ViewWindow> aVWList = aVM->getViews();
+       for ( int i = 0; i < aVWList.count(); i++ ) {
+         SUPERVGraph_ViewFrame* aVW = dynamic_cast<SUPERVGraph_ViewFrame*>( aVWList[i] );
+         QObjectList* aMainList = aVW->queryList("SUPERVGUI_Main");
+         if ( aMainList->count() == 1 ) {
+           SUPERVGUI_Main* aMain = dynamic_cast<SUPERVGUI_Main*>( aMainList->first() );
+           if ( aMain )
+             if ( !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR()) // equal dataflows
+                  && 
+                  aMain != this ) // not equal mains
+               aMain->getCanvas()->merge();
+         }
+       }
+      }
+    }
+  }
+}
+
 void SUPERVGUI_Main::run( const bool andSuspend ) {
   Trace("SUPERVGUI_Main::run");
   if ( SUPERV_isNull(dataflow) ) 
index 45fb8e0cb3eca715d9473903c9abc1216184643a..bb0647643d62a091697dbdbe129d2def04b25340 100644 (file)
@@ -158,6 +158,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View {
     void onSubGraphActivated( SUIT_ViewWindow* );
 
     void onShowToolbar();
+
+    void onObjectCreatedDeleted(); // mkr : PAL8237
  
   private slots:
     void chooseData(QListViewItem* item);