[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Mon Sep 12 19:25:04 CEST 2005


SVN commit 460011 by staikos:

memory leak fixes


 M  +1 -4      kstiface_impl.cpp  
 M  +18 -16    kstimagedialog_i.cpp  
 M  +2 -2      kstplugindialog_i.cpp  


--- trunk/extragear/graphics/kst/kst/kstiface_impl.cpp #460010:460011
@@ -1732,13 +1732,10 @@
     if (lowerZ > upperZ) {
       return QString::null;
     }
-    KPalette* pal = new KPalette(paletteName);
-    if (!pal) {
-      return QString::null;
-    }
     if (numContours < 1) {
       return QString::null;
     }
+    KPalette* pal = new KPalette(paletteName);
     matrix->readLock();
     image = new KstImage(imgtag, matrix, lowerZ, upperZ, false, pal,
                          numContours, contourColor.isValid() ? contourColor : QColor("darkBlue"), 0);
--- trunk/extragear/graphics/kst/kst/kstimagedialog_i.cpp #460010:460011
@@ -337,18 +337,11 @@
     }
   } else {
     // get the current or new parameters as required
-    KPalette* pPalette;
     QColor pContourColor;
     double pLowerZ, pUpperZ;
     int pNumContours, pContourWeight;
     bool pRealTimeAutoThreshold, pUseVariableWeight;
     
-    if (_paletteDirty) {
-      pPalette = new KPalette(_palette->currentText());
-    } else {
-      pPalette = imPtr->palette();
-    }
-  
     if (_lowerZDirty) {
       pLowerZ = _lowerZ->text().toDouble();
     } else {
@@ -405,16 +398,25 @@
     // current image type
     if (imPtr->hasContourMap() && !imPtr->hasColorMap()) {
       imPtr->changeToContourOnly(imPtr->tagName(), pMatrix, pNumContours, pContourColor,
-                                 pUseVariableWeight ? -1 : pContourWeight);
-    } else if (imPtr->hasColorMap() && !imPtr->hasContourMap()) {
-      imPtr->changeToColorOnly(imPtr->tagName(), pMatrix, pLowerZ, pUpperZ, 
-                               pRealTimeAutoThreshold, pPalette);
+          pUseVariableWeight ? -1 : pContourWeight);
     } else {
-      // images always have at least one of color or contour maps
-      imPtr->changeToColorAndContour(imPtr->tagName(), pMatrix, pLowerZ, pUpperZ, 
-                                     pRealTimeAutoThreshold, pPalette,
-                                     pNumContours, pContourColor,
-                                     pUseVariableWeight ? -1 : pContourWeight);
+      KPalette *palette;
+      if (_paletteDirty) {
+        palette = new KPalette(_palette->currentText());
+      } else {
+        palette = imPtr->palette();
+      }
+
+      if (imPtr->hasColorMap() && !imPtr->hasContourMap()) {
+        imPtr->changeToColorOnly(imPtr->tagName(), pMatrix, pLowerZ, pUpperZ, 
+            pRealTimeAutoThreshold, palette);
+      } else {
+        // images always have at least one of color or contour maps
+        imPtr->changeToColorAndContour(imPtr->tagName(), pMatrix, pLowerZ, pUpperZ, 
+            pRealTimeAutoThreshold, palette,
+            pNumContours, pContourColor,
+            pUseVariableWeight ? -1 : pContourWeight);
+      }
     }
   }
   
--- trunk/extragear/graphics/kst/kst/kstplugindialog_i.cpp #460010:460011
@@ -158,8 +158,8 @@
 
 
 void KstPluginDialogI::_fillFieldsForEdit() {
-  if (DP == 0L) {
-    return; // shouldn't be needed
+  if (!DP || !DP->plugin()) { // plugin() can be null if the kst file is invalid
+    return;
   }
   DP->readLock();
   _tagName->setText(DP->tagName());


More information about the Kst mailing list