Salome HOME
Ref #250 - Fatal error after Join all selections operation
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Widget.cxx
index 42bbaf6cc909fe516c7a3a812c1ba1fa7df01f37..e997fe69fe3fc1e9bab18fbe1ee083c040a3e9c2 100644 (file)
@@ -665,13 +665,17 @@ void CurveCreator_Widget::onJoin()
   }
   stopActionMode();
 
-  int aMainSect = aSections[0];
-  int aMainSectSize = myCurve->getNbPoints(aMainSect);
-  for( int i = 1 ; i < aSections.size() ; i++ ){
-    int aSectNum = aSections[i] - (i-1);
-    myCurve->join( aMainSect, aSectNum );
-    mySectionView->sectionsRemoved( aSectNum );
+  std::list<int> aSectionsToJoin;
+  for( int i = 0; i < aSections.size() ; i++ ){
+    aSectionsToJoin.push_back( aSections[i] );
+  }
+
+  if ( myCurve->join( aSectionsToJoin ) )
+  {
+    for( int i = 0, aSectionsSize = aSectionsToJoin.size(); i < aSectionsSize; i++ )
+      mySectionView->sectionsRemoved( i );
   }
+
   updateUndoRedo();
 }
 
@@ -708,7 +712,13 @@ void CurveCreator_Widget::onJoinAll()
   if( !myCurve )
     return;
   stopActionMode();
-  myCurve->join( 0, myCurve->getNbSections()-1 );
+
+  std::list<int> aSectionsToJoin;
+  for( int i = 0, aNb = myCurve->getNbSections(); i < aNb ; i++ ){
+    aSectionsToJoin.push_back( i );
+  }
+  bool aRes = myCurve->join( aSectionsToJoin );
+
   mySectionView->reset();
   updateActionsStates();
   updateUndoRedo();