[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Nov 17 20:10:19 CET 2005


SVN commit 481070 by staikos:

simplify and remove deadlock


 M  +25 -30    kstfilterdialog_i.cpp  


--- trunk/extragear/graphics/kst/kst/kstfilterdialog_i.cpp #481069:481070
@@ -212,51 +212,46 @@
 bool KstFilterDialogI::createCurve(KstPluginPtr plugin) {
   KstVectorPtr xVector;
   KstVectorPtr yVector;
-  bool rc = false;
 
-  // Generate new fit name
-  QString c_name = KST::suggestCurveName(plugin->tagName(), true);
-
+  KST::vectorList.lock().readLock();
   KstVectorList::Iterator it = KST::vectorList.findTag(_xvector);
   if (it != KST::vectorList.end()) {
     xVector = *it;
   }
+  KST::vectorList.lock().readUnlock();
 
   if (plugin->outputVectors().contains(plugin->plugin()->data()._filterOutputVector)) {
     yVector = plugin->outputVectors()[plugin->plugin()->data()._filterOutputVector];
   }
 
-  if (xVector && yVector) {
-    plugin->setDirty();
-    KstVCurvePtr fit = new KstVCurve(c_name, KstVectorPtr(xVector), KstVectorPtr(yVector), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), _w->_curveAppearance->color());
+  if (!xVector || !yVector) {
+    return false;
+  }
+  plugin->setDirty();
+  QString c_name = KST::suggestCurveName(plugin->tagName(), true);
+  KstVCurvePtr fit = new KstVCurve(c_name, KstVectorPtr(xVector), KstVectorPtr(yVector), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), KstVectorPtr(0L), _w->_curveAppearance->color());
 
-    fit->setHasPoints(_w->_curveAppearance->showPoints());
-    fit->setHasLines(_w->_curveAppearance->showLines());
-    fit->setHasBars(_w->_curveAppearance->showBars());
-    fit->setLineWidth(_w->_curveAppearance->lineWidth());
-    fit->setLineStyle(_w->_curveAppearance->lineStyle());
-    fit->Point.setType(_w->_curveAppearance->pointType());
-    fit->setBarStyle(_w->_curveAppearance->barStyle());
-    fit->setPointDensity(_w->_curveAppearance->pointDensity());
+  fit->setHasPoints(_w->_curveAppearance->showPoints());
+  fit->setHasLines(_w->_curveAppearance->showLines());
+  fit->setHasBars(_w->_curveAppearance->showBars());
+  fit->setLineWidth(_w->_curveAppearance->lineWidth());
+  fit->setLineStyle(_w->_curveAppearance->lineStyle());
+  fit->Point.setType(_w->_curveAppearance->pointType());
+  fit->setBarStyle(_w->_curveAppearance->barStyle());
+  fit->setPointDensity(_w->_curveAppearance->pointDensity());
 
-    // add the curve to the plot...
-    KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_window));
-    if (w && w->view()->findChild(_plotName)) {
-      Kst2DPlotPtr plot = kst_cast<Kst2DPlot>(w->view()->findChild(_plotName));
-      if (plot) {
-        plot->addCurve(fit.data());
-        w->view()->paint(P_PAINT);
-      }
+  KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_window));
+  if (w && w->view()->findChild(_plotName)) {
+    Kst2DPlotPtr plot = kst_cast<Kst2DPlot>(w->view()->findChild(_plotName));
+    if (plot) {
+      plot->addCurve(fit.data());
     }
-
-    KST::dataObjectList.lock().writeLock();
-    KST::dataObjectList.append(fit.data());
-    KST::dataObjectList.lock().writeUnlock();
-
-    rc = true;
   }
 
-  return rc;
+  KST::dataObjectList.lock().writeLock();
+  KST::dataObjectList.append(fit.data());
+  KST::dataObjectList.lock().writeUnlock();
+  return true;
 }
 
 


More information about the Kst mailing list