[Kst] [Bug 124367] copying plots in layout mode leads to chaos

Andrew Walker arwalker at sumusltd.com
Tue Mar 28 20:30:31 CEST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=124367         
arwalker sumusltd com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From arwalker sumusltd com  2006-03-28 20:30 -------
SVN commit 523647 by arwalker:

BUG:124367 Ensure a unique plot name. Nicolas, I believe this should fix the problem you described. Thanks for describing the scenario so cleanly.

 M  +30 -5     kst2dplot.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #523646:523647
 @ -435,11 +435,36  @
   _type = "Plot";
 
   if (name.isEmpty()) {
-    plotName = KST::suggestPlotName();
+    plotName = i18n("Copy-%1").arg(plot.tagName());
   } else {
     plotName = name;
   }
 
+  KstApp *app = KstApp::inst();
+  KMdiIterator<KMdiChildView*> *iter;
+  bool duplicate = true;
+  static int last = 0;
+  
+  // check for unique plot name
+  while (duplicate) {
+    duplicate = false;
+    iter = app->createIterator();
+    while (iter->currentItem() && !duplicate) {
+      KMdiChildView *childview = iter->currentItem();
+      KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview);
+      if (viewwindow) {
+        if (viewwindow->view()->findChild(plotName)) {
+          ++last;
+          plotName = i18n("Copy%1-%2").arg(last).arg(plot.tagName());
+          duplicate = true;
+          break;
+        }
+      }
+      iter->next();
+    }
+    app->deleteIterator(iter);
+  }
+  
   commonConstructor(plotName,
                     plot._xScaleMode,
                     plot._yScaleMode,
 @ -3256,14 +3281,14  @
 
 
 void Kst2DPlot::copyObjectQuietly(KstViewObject& parent, const QString& name) const {
-  QString plotName;
-
+  QString plotName; 
+  
   if (name.isEmpty()) {
-    plotName = KST::suggestPlotName();
+    plotName = i18n("Copy-%1").arg(tagName());
   } else {
     plotName = name;
   }
-
+  
   parent.appendChild(new Kst2DPlot(*this, plotName), true);
 }


More information about the Kst mailing list