[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Sat Jul 24 05:37:08 CEST 2004


CVS commit by staikos: 

- keep headers in alphabetical order to avoid dupes (had many of them in the
 past) and make it easy to spot ones that should be removed
- initialize pointer to 0 to avoid crash
- remove possible memory leak
- make "image" private in kst2dplot - let's try to slowly clean up these
  public member variables


  M +14 -4     kst2dplot.cpp   1.175
  M +3 -4      kst2dplot.h   1.72
  M +5 -6      kstdatamanager_i.cpp   1.63
  M +4 -4      kstimage.cpp   1.3
  M +1 -1      kstplotdialog_i.cpp   1.65


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.174:1.175
@@ -1253,5 +1253,5 @@ void Kst2DPlot::draw(QPainter &p, KstPai
     for (int i=0; i< Hx-Lx;i++) {
       for (int j=0; j<Hy-Ly; j++) {
-        QRgb rgb = image->getMappedColor(((i + Lx - _b_X) / _m_X),
+        QRgb rgb = _image->getMappedColor(((i + Lx - _b_X) / _m_X),
                                             ((j + Ly - _b_Y) / _m_Y));
         tempImage.setPixel(i,j, rgb);
@@ -3746,6 +3746,7 @@ bool Kst2DPlot::prevMarker(const double 
 }
 
+
 void Kst2DPlot::setImage(KstImagePtr inImage, bool set_dirty) {
-  image = inImage;
+  _image = inImage;
   if (set_dirty) {
     setDirty();
@@ -3753,6 +3754,7 @@ void Kst2DPlot::setImage(KstImagePtr inI
 }
 
+
 void Kst2DPlot::removeImage() {
-  image = 0L;
+  _image = 0L;
 }
 
@@ -3757,7 +3759,15 @@ void Kst2DPlot::removeImage() {
 }
 
+
 bool Kst2DPlot::hasImage() {
-  return (image != 0L);
+  return (_image != 0L);
 }
+
+
+KstImagePtr Kst2DPlot::image() const {
+  return _image;
+}
+
+
 #include "kst2dplot.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.71:1.72
@@ -151,7 +151,4 @@ public:
   KstBaseCurveList Curves;
 
-  /** The single allowed image for the plot */
-  KstImagePtr image;
-
   void GenerateDefaultLabels();
 
@@ -214,5 +211,5 @@ public:
   void removeImage();
   bool hasImage();
-
+  KstImagePtr image() const;
 
 signals:
@@ -321,4 +318,6 @@ private:
   double _oldXAlignment;
   double _m_X, _b_X, _m_Y, _b_Y;
+  /** The single allowed image for the plot */
+  KstImagePtr _image;
 
   /** Plot Markers.  This needs to remain sorted **/

--- kdeextragear-2/kst/kst/kstdatamanager_i.cpp  #1.62:1.63
@@ -36,6 +36,9 @@
 
 // application specific includes
+#include "imagedialog.h"
 #include "kst.h"
 #include "kst2dplot.h"
+#include "kstarray.h"
+#include "kstarraydialog_i.h"
 #include "kstcurvedialog_i.h"
 #include "kstdatacollection.h"
@@ -46,4 +49,6 @@
 #include "kstfilteredvector.h"
 #include "ksthsdialog_i.h"
+#include "kstimage.h"
+#include "kstimagedialog_i.h"
 #include "kstplotdialog_i.h"
 #include "kstplugin.h"
@@ -55,10 +60,4 @@
 #include "vectorselector.h"
 
-#include "kstimage.h"
-#include "kstimagedialog_i.h"
-#include "imagedialog.h"
-
-#include "kstarray.h"
-#include "kstarraydialog_i.h"
 
 static QMap<int,Kst2DPlotPtr> PlotMap;

--- kdeextragear-2/kst/kst/kstimage.cpp  #1.2:1.3
@@ -21,10 +21,10 @@
 #include <math.h>
 
-KstImage::KstImage(QDomElement& e) : KstDataObject(e) {
+KstImage::KstImage(QDomElement& e) : KstDataObject(e), _pal(0L) {
   commonConstructor();
 }
 
 
-KstImage::KstImage(const QString &in_tag, KstArrayPtr in_array) : KstDataObject() {
+KstImage::KstImage(const QString &in_tag, KstArrayPtr in_array) : KstDataObject(), _pal(0L) {
   commonConstructor();
   _typeString = i18n("Image");
@@ -74,6 +74,5 @@ QRgb KstImage::getMappedColor(double x, 
       index = 0;
     }
-    QColor colour = _pal->color(index);
-    return colour.rgb();
+    return _pal->color(index).rgb();
   }
   return _backColor.rgb();
@@ -82,4 +81,5 @@ QRgb KstImage::getMappedColor(double x, 
 
 void KstImage::setPalette(KPalette* pal) {
+  delete _pal;
   _pal = pal;
 }

--- kdeextragear-2/kst/kst/kstplotdialog_i.cpp  #1.64:1.65
@@ -1213,5 +1213,5 @@ void KstPlotDialogI::updateImageCombo() 
     for (KstImageList::iterator it = allImages.begin(); it != allImages.end(); it++) {
       ImageCombo->insertItem((*it)->tagName());
-      if (plot->image == (*it)) {
+      if (plot->image() == (*it)) {
         plotImage = i;
       }





More information about the Kst mailing list