Index: kabc/resource.cpp
===================================================================
--- kabc/resource.cpp	(wersja 821592)
+++ kabc/resource.cpp	(kopia robocza)
@@ -207,10 +207,13 @@
   public:
     Private()
       : mAddressBook( 0 )
+      , removeDistributionListEnabled( true )
     {
     }
 
     AddressBook *mAddressBook;
+    /** used to disable removeDistributionList() when clear() is called */
+    bool removeDistributionListEnabled : 1;
 };
 
 Resource::Resource()
@@ -350,7 +353,10 @@
 {
   mAddrMap.clear();
 
+  d->removeDistributionListEnabled = false;
   qDeleteAll( mDistListMap );
+  d->removeDistributionListEnabled = true;
+  mDistListMap.clear();
 }
 
 void Resource::insertDistributionList( DistributionList *list )
@@ -362,6 +368,8 @@
 
 void Resource::removeDistributionList( DistributionList *list )
 {
+  if ( !d->removeDistributionListEnabled )
+    return;
   Q_ASSERT( list );
 
   DistributionListMap::iterator it = mDistListMap.find( list->identifier() );
@@ -374,12 +382,7 @@
 
 DistributionList *Resource::findDistributionListByIdentifier( const QString &identifier )
 {
-  DistributionListMap::const_iterator it = mDistListMap.find( identifier );
-  if ( it != mDistListMap.end() ) {
-    return it.value();
-  }
-
-  return 0;
+  return mDistListMap.value( identifier );
 }
 
 DistributionList *Resource::findDistributionListByName( const QString &name,
@@ -409,23 +412,15 @@
 
 QList<DistributionList*> Resource::allDistributionLists()
 {
-  QList<DistributionList*> results;
-
-  DistributionListMap::const_iterator it    = mDistListMap.begin();
-  DistributionListMap::const_iterator endIt = mDistListMap.end();
-  for ( ; it != endIt; ++it ) {
-    results += it.value();
-  }
-
-  return results;
+  return mDistListMap.values();
 }
 
 QStringList Resource::allDistributionListNames() const
 {
   QStringList results;
 
-  DistributionListMap::const_iterator it    = mDistListMap.begin();
-  DistributionListMap::const_iterator endIt = mDistListMap.end();
+  DistributionListMap::const_iterator it    = mDistListMap.constBegin();
+  DistributionListMap::const_iterator endIt = mDistListMap.constEnd();
   for ( ; it != endIt; ++it ) {
     results += it.value()->name();
   }
