[Digikam-devel] [Bug 140417] Crash Digikam when delete image

Marcel Wiesweg marcel.wiesweg at gmx.de
Tue Jan 23 16:44:44 GMT 2007


------- 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=140417         




------- Additional Comments From marcel.wiesweg gmx de  2007-01-23 17:44 -------
SVN commit 626532 by mwiesweg:

Delete ImageInfo objects only after the tabs have had a chance to save their changes.
Don't use setAutoDelete, it is more explicit like this.

CCBUG: 140417


 M  +33 -1     imagepropertiessidebardb.cpp  


--- trunk/extragear/graphics/digikam/libs/imageproperties/imagepropertiessidebardb.cpp #626531:626532
 @ -65,6 +65,7  @
         dirtyDesceditTab    = false;
         hasPrevious         = false;
         hasNext             = false;
+        hasImageInfoOwnership = false;
     }
 
     bool              dirtyDesceditTab;
 @ -75,6 +76,8  @
 
     bool              hasPrevious;
     bool              hasNext;
+
+    bool              hasImageInfoOwnership;
 };
 
 ImagePropertiesSideBarDB::ImagePropertiesSideBarDB(QWidget *parent, const char *name, QSplitter *splitter, 
 @ -151,6 +154,16  @
     m_currentRect        = rect;
     m_image              = img;
 
+    // The list _may_ have autoDelete set to true.
+    // Keep old ImageInfo objects from being deleted
+    // until the tab has had the chance to save changes and clear lists.
+    QPtrList<ImageInfo> temporaryList;
+    if (d->hasImageInfoOwnership)
+    {
+        temporaryList = d->currentInfos;
+        d->hasImageInfoOwnership = false;
+    }
+
     QPtrList<ImageInfo> list;
     if (info)
         list.append(info);
 @ -162,6 +175,12  @
     d->dirtyDesceditTab  = false;
 
     slotChangedTab( getActiveTab() );
+
+    // now delete old objects, after slotChangedTab
+    for (ImageInfo *info = temporaryList.first(); info; info = temporaryList.next())
+    {
+        delete info;
+    }
 }
 
 void ImagePropertiesSideBarDB::itemChanged(QPtrList<ImageInfo> infos)
 @ -172,6 +191,14  @
     m_currentURL         = infos.first()->kurl();
     m_currentRect        = QRect();
     m_image              = 0;
+
+    QPtrList<ImageInfo> temporaryList;
+    if (d->hasImageInfoOwnership)
+    {
+        temporaryList = d->currentInfos;
+        d->hasImageInfoOwnership = false;
+    }
+
     d->currentInfos      = infos;
 
     m_dirtyPropertiesTab = false;
 @ -180,11 +207,16  @
     d->dirtyDesceditTab  = false;
 
     slotChangedTab( getActiveTab() );
+
+    for (ImageInfo *info = temporaryList.first(); info; info = temporaryList.next())
+    {
+        delete info;
+    }
 }
 
 void ImagePropertiesSideBarDB::takeImageInfoOwnership(bool takeOwnership)
 {
-    d->currentInfos.setAutoDelete(takeOwnership);
+    d->hasImageInfoOwnership = takeOwnership;
 }



More information about the Digikam-devel mailing list