[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/graphics/digikam/libs/greycstoration
From:       Gilles Caulier <caulier.gilles () gmail ! com>
Date:       2007-03-27 7:35:32
Message-ID: 1174980932.143107.8480.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 647043 by cgilles:

digiKam from trunk : CImg:: GreyCstoration interface : never use CImg::wait() method \
with QThread. Memory is dirty and computation can crash with some environnements.

David : the crash is not reproductible on my computer, but valgrind report the dirty \
memory. Please check what can be wrong in CImg::wait(). Thanks in advance.

Thanks to Thorsten Schnebeck to have reported this problem...

CCMAIL: thorsten.schnebeck@gmx.net
CCMAIL: David.Tschumperle@greyc.ensicaen.fr


 M  +34 -31    greycstorationiface.cpp  


--- trunk/extragear/graphics/digikam/libs/greycstoration/greycstorationiface.cpp \
#647042:647043 @@ -126,8 +126,6 @@
         DDebug() << "Stop Greycstoration computation..." << endl;
 
         d->img.greycstoration_stop();
-        // to be sure than Greycstoration thread is finished, we wait a little.
-        cimg::wait(500);
     }
 
     Digikam::DImgThreadedFilter::stopComputation();
@@ -161,10 +159,10 @@
         {
             for (x = 0; x < imageWidth; x++)
             {
-                d->img(x, y, 0) = ptr[0];        // blue.
-                d->img(x, y, 1) = ptr[1];        // green.
-                d->img(x, y, 2) = ptr[2];        // red.
-                d->img(x, y, 3) = ptr[3];        // alpha.
+                d->img(x, y, 0) = ptr[0];        // Blue.
+                d->img(x, y, 1) = ptr[1];        // Green.
+                d->img(x, y, 2) = ptr[2];        // Red.
+                d->img(x, y, 3) = ptr[3];        // Alpha.
                 ptr += 4;
             }
         }
@@ -177,10 +175,10 @@
         {
             for (x = 0; x < imageWidth; x++)
             {
-                d->img(x, y, 0) = ptr[0];        // blue.
-                d->img(x, y, 1) = ptr[1];        // green.
-                d->img(x, y, 2) = ptr[2];        // red.
-                d->img(x, y, 3) = ptr[3];        // alpha.
+                d->img(x, y, 0) = ptr[0];        // Blue.
+                d->img(x, y, 1) = ptr[1];        // Green.
+                d->img(x, y, 2) = ptr[2];        // Red.
+                d->img(x, y, 3) = ptr[3];        // Alpha.
                 ptr += 4;
             }
         }
@@ -268,7 +266,7 @@
 
 void GreycstorationIface::restoration()
 {
-    for (uint iter=0 ; !m_cancel && (iter < d->settings.nbIter) ; iter++)
+    for (uint iter = 0 ; !m_cancel && (iter < d->settings.nbIter) ; iter++)
     {
         // This function will start a thread running one iteration of the \
                GREYCstoration filter.
         // It returns immediately, so you can do what you want after (update a \
progress bar for @@ -285,7 +283,7 @@
                                   d->settings.fastApprox,
                                   d->settings.tile,
                                   d->settings.btile,
-                                  2);
+                                  2);                     // 2 separated threads to \
compute.  
         iterationLoop(iter);
     }
@@ -338,7 +336,7 @@
                                   d->settings.fastApprox,
                                   d->settings.tile,
                                   d->settings.btile,
-                                  2);
+                                  2);                     // 2 separated threads to \
compute.  iterationLoop(iter);
     }
 }
@@ -363,25 +361,25 @@
 
     d->img.resize(w, h, 1, -100, init);
 
-    for (uint iter=0 ; !m_cancel && (iter < d->settings.nbIter) ; iter++)
+    for (uint iter = 0 ; !m_cancel && (iter < d->settings.nbIter) ; iter++)
     {
         // This function will start a thread running one iteration of the \
                GREYCstoration filter.
         // It returns immediately, so you can do what you want after (update a \
progress bar for  // instance).
         d->img.greycstoration_run(d->mask,
-                                    d->settings.amplitude,
-                                    d->settings.sharpness,
-                                    d->settings.anisotropy,
-                                    d->settings.alpha,
-                                    d->settings.sigma,
-                                    d->settings.dl,
-                                    d->settings.da,
-                                    d->settings.gaussPrec,
-                                    d->settings.interp,
-                                    d->settings.fastApprox,
-                                    d->settings.tile,
-                                    d->settings.btile,
-                                    2);
+                                  d->settings.amplitude,
+                                  d->settings.sharpness,
+                                  d->settings.anisotropy,
+                                  d->settings.alpha,
+                                  d->settings.sigma,
+                                  d->settings.dl,
+                                  d->settings.da,
+                                  d->settings.gaussPrec,
+                                  d->settings.interp,
+                                  d->settings.fastApprox,
+                                  d->settings.tile,
+                                  d->settings.btile,
+                                  2);                     // 2 separated threads to \
compute.  iterationLoop(iter);
     }
 }
@@ -398,17 +396,22 @@
 
 void GreycstorationIface::iterationLoop(uint iter)
 {
+    uint mp = iter*100;
+
     do
     {
         if (m_parent && !m_cancel)
         {
             // Update the progress bar in dialog. We simply computes the global
             // progression indice (including all iterations).
-            postProgress((uint)((iter*100 + \
d->img.greycstoration_progress())/d->settings.nbIter)); +
+            uint p = (uint)((iter*100 + \
d->img.greycstoration_progress())/d->settings.nbIter); +            if (p == mp+1)
+            {
+                postProgress(p);
+                mp = p;
+            }
         }
-
-        // Wait a little bit
-        cimg::wait(100);
     }
     while (d->img.greycstoration_is_running() && !m_cancel);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic