Salome HOME
fix for 7817: in removeArrayChild() the returned list of children of myArray is check...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Main.cxx
index 667670f50c7d8459b3235889f7a5556724f19e17..e7317460b29ac65c494ec039d415999c36315a4b 100644 (file)
@@ -37,6 +37,7 @@ using namespace std;
 #include "QAD_Application.h"
 #include "QAD_RightFrame.h"
 #include "QAD_SpinBoxDbl.h"
+#include "QAD_MessageBox.h"
 
 #include "NOTIFICATION.hxx"
 #include "SALOME_Event.hxx"
@@ -617,16 +618,17 @@ void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le
 */
 void SUPERVGUI_Main::addNode() {
   Trace("SUPERVGUI_Main::addNode");
-  if (SUPERV_isNull(dataflow)) return;
+  bool error = SUPERV_isNull( dataflow );
+  if ( error ) 
+    return;
 
-  if (dataflow->IsExecuting()) {
-    if (QMessageBox::warning(QAD_Application::getDesktop(), 
-                            tr("WARNING"), tr("MSG_GRAPH_ISRUN"),
-                            QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
-      return;       
-    } else {
+  if ( dataflow->IsExecuting() ) {
+    error = QAD_MessageBox::warn2( QAD_Application::getDesktop(), // 0=Yes, 1=No
+      tr("WARNING"), tr("MSG_GRAPH_ISRUN"), tr( "BUT_YES" ), tr( "BUT_NO" ), 0, 1, 0 );
+    if ( error ) // user selected NOT to kill dataflow and NOT to add new node
+      return;
+    else  // user selected to kill the dataflow and add new node after that
       kill();
-    }
   }
   
   Editing(); // PAL6170: GUI->Engine: setting "Editing" flag 
@@ -1223,15 +1225,17 @@ void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode)
   // 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;
+    if ( aChList ) { // asv 27.01.05 : fix for 7817
+      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;
+       }
       }
-    }
+    } // end of if ( ChList )
   }
 }