[Digikam-devel] [Bug 133026] crashes on systems using hyperthreading

Gilles Caulier caulier.gilles at free.fr
Thu Oct 26 07:29:14 BST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=133026         




------- Additional Comments From caulier.gilles free fr  2006-10-26 08:29 -------
SVN commit 599179 by cgilles:

digikam  from trunk : make a deep copy of QString in threaded image filter constructor to prevent crash into Hyperthreading CPU.

To digiKam users : feedback is welcome...

CCBUGS:133026
CCMAIL: digikam-devel kde org

 M  +33 -25    dimgthreadedfilter.cpp  
 M  +33 -31    dimgthreadedfilter.h  


--- trunk/extragear/graphics/digikam/libs/dimg/filters/dimgthreadedfilter.cpp #599178:599179
 @ -1,5 +1,4  @
 /* ============================================================
- * File  : dimgthreadedfilter.cpp
  * Author: Gilles Caulier <caulier dot gilles at kdemail dot net>
  * Date  : 2005-05-25
  * Description : threaded image filter class.
 @ -24,6 +23,7  @
 #include <qobject.h>
 #include <qdatetime.h> 
 #include <qevent.h>
+#include <qdeepcopy.h>
 
 // KDE includes.
 
 @ -36,34 +36,42  @
 namespace Digikam
 {
 
-DImgThreadedFilter::DImgThreadedFilter(DImg *orgImage, QObject *parent, QString name)
+DImgThreadedFilter::DImgThreadedFilter(DImg *orgImage, QObject *parent, 
+                                       const QString& name)
                   : QThread()
 {
     // remove meta data
-    m_orgImage = orgImage->copyImageData();
-    m_parent   = parent;
-    m_cancel   = false;
-    m_name     = name;
+    m_orgImage      = orgImage->copyImageData();
+    m_parent        = parent;
+    m_cancel        = false;
 
-    m_master   = 0;
-    m_slave    = 0;
+    // See B.K.O #133026: make a deep copy of Qstring to prevent crash 
+    // on Hyperthreading computer.
+    m_name          = QDeepCopy<QString>(name);
+
+    m_master        = 0;
+    m_slave         = 0;
     m_progressBegin = 0;
     m_progressSpan  = 100;
 }
 
-DImgThreadedFilter::DImgThreadedFilter(DImgThreadedFilter *master, const DImg &orgImage, const DImg &destImage,
-                                       int progressBegin, int progressEnd, QString name)
+DImgThreadedFilter::DImgThreadedFilter(DImgThreadedFilter *master, const DImg &orgImage, 
+                                       const DImg &destImage, int progressBegin, int progressEnd, 
+                                       const QString& name)
 {
-    m_orgImage  = orgImage;
-    m_destImage = destImage;
-    m_parent    = 0;
-    m_cancel    = false;
-    m_name      = name;
+    m_orgImage      = orgImage;
+    m_destImage     = destImage;
+    m_parent        = 0;
+    m_cancel        = false;
 
-    m_master    = master;
-    m_slave     = 0;
+    // See B.K.O #133026: make a deep copy of Qstring to prevent crash 
+    // on Hyperthreading computer.
+    m_name          = QDeepCopy<QString>(name);
+
+    m_master        = master;
+    m_slave         = 0;
     m_progressBegin = progressBegin;
-    m_progressSpan = progressEnd - progressBegin;
+    m_progressSpan  = progressEnd - progressBegin;
 
     m_master->setSlave(this);
 }
 @ -75,8 +83,6  @
         m_master->setSlave(0);
 }
 
-
-
 void DImgThreadedFilter::initFilter(void)
 {
     m_destImage.reset();         
 @ -123,9 +129,9  @
     else if (m_parent)
     {
        EventData *eventData = new EventData();
-       eventData->progress = progress;
-       eventData->starting = starting;
-       eventData->success  = success;
+       eventData->progress  = progress;
+       eventData->starting  = starting;
+       eventData->success   = success;
        QApplication::postEvent(m_parent, new QCustomEvent(QEvent::User, eventData));
     }
 }
 @ -150,7 +156,8  @
           postProgress(0, false, true);
           
        kdDebug() << m_name
-                 << "::End of computation !!! ... ( " << startDate.secsTo(endDate) << " s )" << endl;
+                 << "::End of computation !!! ... ( " << startDate.secsTo(endDate) << " s )" 
+                 << endl;
     }
     else
     {
 @ -158,7 +165,8  @
           postProgress(0, false, false);
           
        kdDebug() << m_name
-                 << "::Computation aborted... ( " << startDate.secsTo(endDate) << " s )" << endl;
+                 << "::Computation aborted... ( " << startDate.secsTo(endDate) << " s )" 
+                 << endl;
     }
 }
 
--- trunk/extragear/graphics/digikam/libs/dimg/filters/dimgthreadedfilter.h #599178:599179
 @ -1,5 +1,4  @
 /* ============================================================
- * File  : dimgthreadedfilter.h
  * Author: Gilles Caulier <caulier dot gilles at kdemail dot net>
  * Date  : 2005-05-25
  * Description : threaded image filter class.
 @ -46,8 +45,7  @
 
 public:
 
-// Class used to post status of computation to parent.
-
+/** Class used to post status of computation to parent. */
 class EventData
 {
     public:
 @ -65,7 +63,8  @
 
 public:
     
-    DImgThreadedFilter(DImg *orgImage, QObject *parent=0, QString name=QString::null);
+    DImgThreadedFilter(DImg *orgImage, QObject *parent=0, 
+                       const QString& name=QString::null);
     
     ~DImgThreadedFilter();
     
 @ -78,49 +77,44  @
     
 protected:
 
-    // Copy of original Image data.
+    /** Copy of original Image data. */
     DImg      m_orgImage;
 
-    // Output image data.
+    /** Output image data. */
     DImg      m_destImage;
     
-    // Filter name.
+    /** Filter name.*/
     QString   m_name;
     
-    // Used to stop compution loop.
+    /** Used to stop compution loop. */
     bool      m_cancel;
 
-    // To post event from thread to parent.    
+    /** To post event from thread to parent. */
     QObject  *m_parent;
 
 protected:
 
-    // Start filter operation before threaded method. Must be calls by your constructor.
+    /** Start filter operation before threaded method. Must be calls by your constructor. */
     virtual void initFilter(void);
         
-    // List of threaded operations by filter.
+    /** List of threaded operations by filter. */
     virtual void run(){ startComputation(); };
     
-    // Main image filter method.
+    /** Main image filter method. */
     virtual void filterImage(void){};
     
-    // Clean up filter data if necessary. Call by stopComputation() method.
+    /** Clean up filter data if necessary. Call by stopComputation() method. */
     virtual void cleanupFilter(void){};
     
-    // Post Event to parent about progress. Warning: you need to delete 
-    // 'EventData' instance to 'customEvent' parent implementation.
+    /** Post Event to parent about progress. Warning: you need to delete 
+        'EventData' instance to 'customEvent' parent implementation. */
     void postProgress(int progress=0, bool starting=true, bool success=false);
-    
+
 protected:
 
-    // Support for chaining two filters as master and thread
+    /**
+      Support for chaining two filters as master and thread.
 
-    // The current slave. Any filter might want to use another filter while processing.
-    DImgThreadedFilter *m_slave;
-    // The master of this slave filter. Progress info will be routed to this one.
-    DImgThreadedFilter *m_master;
-
-    /*
       Constructor for slave mode:
       Constructs a new slave filter with the specified master.
       The filter will be executed in the current thread.
 @ -129,20 +123,28  @
       that the slave filter uses in the parent filter's progress.
       Any derived filter class that is publicly available to other filters
       should implement an additional constructor using this constructor.
-    */
+      */
     DImgThreadedFilter(DImgThreadedFilter *master, const DImg &orgImage, const DImg &destImage,
-                       int progressBegin=0, int progressEnd=100, QString name=QString::null);
+                       int progressBegin=0, int progressEnd=100, const QString& name=QString::null);
 
-    // inform the master that there is currently a slave. At destruction of the slave, call with slave=0.
+    /** Inform the master that there is currently a slave. At destruction of the slave, call with slave=0. */
     void setSlave(DImgThreadedFilter *slave);
 
-    // The progress span that a slave filter uses in the parent filter's progress
+    /** This method modulates the progress value from the 0..100 span to the span of this slave.
+        Called by postProgress if master is not null. */
+    virtual int modulateProgress(int progress);
+
+protected:
+
+    /** The current slave. Any filter might want to use another filter while processing. */
+    DImgThreadedFilter *m_slave;
+
+    /** The master of this slave filter. Progress info will be routed to this one. */
+    DImgThreadedFilter *m_master;
+
+    /** The progress span that a slave filter uses in the parent filter's progress. */
     int m_progressBegin;
     int m_progressSpan;
-    // This method modulates the progress value from the 0..100 span to the span of this slave.
-    // Called by postProgress if master is not null.
-    virtual int modulateProgress(int progress);
-
 };
 
 }  // NameSpace Digikam



More information about the Digikam-devel mailing list