[PATCH] KABC::DistributionList(Manager)
Tobias Koenig
tokoe at kde.org
Sat Dec 6 15:14:04 GMT 2003
Hi,
during hunting a bug the last 4 days I found some weaknesses in
KABC::DistributionList and KABC::DistributionListManager.
In the first class there is a 'manager->remove( this )' call which
could cause a crash:
In the manager an (autodelete enabled) pointer list with all distlists
is kept. When the manager is destroyed, these distlists are removed from
the internal list and deleted => the d'tor of the distlists is called
which tries to remove the distlist from the internal list (but it's
already removed...) => crash.
The second part adds a static deleter for the DistributionlistManager
singleton.
Ok for commit?
Ciao,
Tobias
--
Can a government that shoots at reporters be democratic?
Separate politics from religion and economy!
-------------- next part --------------
Index: distributionlist.h
===================================================================
RCS file: /home/kde/kdelibs/kabc/distributionlist.h,v
retrieving revision 1.9
diff -p -u -b -r1.9 distributionlist.h
--- distributionlist.h 22 Aug 2003 15:07:55 -0000 1.9
+++ distributionlist.h 6 Dec 2003 15:06:31 -0000
@@ -22,6 +22,7 @@
#define KABC_DISTRIBUTIONLIST_H
#include <kdirwatch.h>
+#include <kstaticdeleter.h>
#include "addressbook.h"
@@ -189,6 +190,8 @@ class DistributionListWatcher : public Q
{
Q_OBJECT
+ friend class KStaticDeleter<DistributionListWatcher>;
+
public:
/**
* Returns the watcher object.
Index: distributionlist.cpp
===================================================================
RCS file: /home/kde/kdelibs/kabc/distributionlist.cpp,v
retrieving revision 1.10
diff -p -u -b -r1.10 distributionlist.cpp
--- distributionlist.cpp 22 Aug 2003 15:07:55 -0000 1.10
+++ distributionlist.cpp 6 Dec 2003 15:06:31 -0000
@@ -35,7 +35,6 @@ DistributionList::DistributionList( Dist
DistributionList::~DistributionList()
{
- mManager->remove( this );
}
void DistributionList::setName( const QString &name )
@@ -239,6 +238,7 @@ bool DistributionListManager::save()
}
DistributionListWatcher* DistributionListWatcher::mSelf = 0;
+static KStaticDeleter<DistributionListWatcher> distListWatcherDeleter;
DistributionListWatcher::DistributionListWatcher()
: QObject( 0, "DistributionListWatcher" )
@@ -259,7 +259,7 @@ DistributionListWatcher::~DistributionLi
DistributionListWatcher *DistributionListWatcher::self()
{
if ( !mSelf )
- mSelf = new DistributionListWatcher();
+ distListWatcherDeleter.setObject( mSelf, new DistributionListWatcher() );
return mSelf;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20031206/f871b013/attachment.sig>
More information about the kde-core-devel
mailing list