Salome HOME
Memory Leaks
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_CanvasPort.cxx
index 198c5ed0a91bcfb7ed2e2f8941b77a2c3140908f..1a5c30b88545e3fc83a1646b52a24d2c53379236 100644 (file)
@@ -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 
@@ -221,7 +221,8 @@ void SUPERVGUI_CanvasPortIn::setValue(const char* theValue)
 
 void SUPERVGUI_CanvasPortIn::setInput() 
 {
-  getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
+  // asv 28.01.05 : set "Editing" flag only on "OK" pressed in BrowseDlg
+  //getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
   if (!myDlg) {
     myDlg = new SUPERVGUI_GetValueDlg(this);
     myDlg->installEventFilter(this);
@@ -272,10 +273,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();
 }
 
@@ -283,19 +291,19 @@ void SUPERVGUI_CanvasPortOut::toStudy()
 {
   Trace("SUPERVGUI_CanvasPortOut::toStudy");
 
-  if (getMain()->getStudy()->getStudyDocument()->GetProperties()->IsLocked()) {
+  // asv 08.02.05 : added && !myInStudy - fix for PAL8105
+  if ( getMain()->getStudy()->getStudyDocument()->GetProperties()->IsLocked() && !myInStudy ) {
     QMessageBox::warning(QAD_Application::getDesktop(), tr("WRN_WARNING"), 
                         tr("WRN_STUDY_LOCKED"));
     return;
   }
 
-  if (!getMain()->isFromStudy()) {
-    if (getMain()->addStudy())
-      getMain()->setAsFromStudy(true);
-  }
   myInStudy = !myInStudy;
   sync();
   getMain()->getCanvas()->update();
+
+  if ( myInStudy ) // put values to study (supervision, supervision->dataflow, supervision->dataflow->runXXX, etc.
+    getMain()->putDataStudy( getEngine(), STUDY_PORT_OUT ); 
 }