[Kde-pim] [patch] kdepimlibs/kabc: fix crash appearing at qDeleteAll ()

Ingo Klöcker kloecker at kde.org
Wed Jun 18 19:50:25 BST 2008


On Wednesday 18 June 2008, Jaroslaw Staniek wrote:
> (for review; enterprise4 branch)
>
> - Resource::clear() fix crash appearing at qDeleteAll(mDistListMap)
> beacuse DistributionList objects' destructor calls
>    Resource::removeDistributionList(), which in turn modifies with
>    mDistListMap. We are now blocking removeDistributionList() when
> qDeleteAll() is called.
>    Instead of erasing() every deleted item from the map, we're
> calling QMap::clear() afterwards.
>
> - simplify code related to mDistListMap: use Qt4 facilities and some
>    more constness

I propose the following solution that avoids adding a member variable at 
the cost of copying mDistListMap:
=====
@@ -350,7 +353,10 @@
 {
   mAddrMap.clear();
 
+  // take a copy of mDistListMap, then clear it and finally qDeleteAll
+  // the copy to avoid problems with removeDistributionList() called by
+  // ~DistributionList().
+  DistributionListMap tempDistListMap( mDistListMap );
+  mDistListMap.clear();
+   qDeleteAll( tempDistListMap );
 -  qDeleteAll( mDistListMap );
 }
 
 void Resource::insertDistributionList( DistributionList *list )
=====

Note that I haven't checked whether Resource::removeDistributionList( 
DistributionList *list ) plays nice if it does not find list in 
mDistListMap.


Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20080618/e24143b1/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list