[Digikam-devel] extragear/graphics/digikam/utilities/imageeditor

Gilles Caulier caulier.gilles at free.fr
Tue Aug 9 19:26:47 BST 2005


SVN commit 444324 by cgilles:

Patch from Owen Hirst to fix crash when histogram is visible.

The histogram thread holds a pointer to the image data. Under certain
conditions, for eg, saving of image and reloading of image data, this image
data pointer is invalidated. Since the thread still holds a pointer to the
invalid pointer and tries to do calculations on it, the application crashes.
Attached patch deletes the histogram thread before reloading the image

CCMAIL: digikam-devel at kde.org
CCBUGS: 109946



 M  +14 -7     canvas.cpp  


--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas.cpp #444323:444324
@@ -346,6 +346,12 @@
         emit signalSelected(false);
     }
 
+    if (d->imageHistogram)
+    {
+        delete d->imageHistogram;
+        d->imageHistogram = 0;
+    }    
+    
     viewport()->setUpdatesEnabled(false);
 
     d->tileCache.clear();
@@ -362,7 +368,7 @@
     viewport()->setUpdatesEnabled(true);
     viewport()->update();
     if (d->showHistogram)
-	    updateHistogram(true);
+       updateHistogram(true);
    
     emit signalChanged(false, false);
     emit signalZoomChanged(d->zoom);
@@ -453,11 +459,12 @@
  */
 bool Canvas::updateHistogram(bool invalidate)
 {
-    if (invalidate && d->imageHistogram) {
-	    delete d->imageHistogram;
-	    d->imageHistogram = 0;
+    if (invalidate && d->imageHistogram) 
+    {
+        delete d->imageHistogram;
+        d->imageHistogram = 0;
     }
-	
+
     if (d->imageHistogram == 0) {
         d->histogramReady = false;
         d->imageHistogram = new ImageHistogram(d->im->getData(),
@@ -710,9 +717,9 @@
 void Canvas::paintHistogram(const QRect& cr)
 {
     if (!d->showHistogram) 
-	    return;
+       return;
     if (!d->histogramPixmap)
-	    return;
+       return;
 
     QRect rcexposed, rc, rctmp;
 



More information about the Digikam-devel mailing list