[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim] mailcommon: Hold strong references in the FolderCollection object cache.
From:       Till Adam <till () kdab ! com>
Date:       2012-02-21 10:45:26
Message-ID: 20120221104526.92C18A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 3b6e3ade255ca5bdce3e2f143344a935cc6c1559 by Till Adam.
Committed on 21/02/2012 at 10:54.
Pushed by tilladam into branch 'master'.

Hold strong references in the FolderCollection object cache.

With the weak reference used before, and nothing really holding longer
living references to these objects, the cache was effectively bypassed,
since for every access new objects were being created. These objects are
needed mostly in the folder proxy models, to check things like whether a
particular folder should be hidden. Keeping effectively all
FolderCollection objects in memory as we now do is not optimal, from a
memory point of view, and could be optimized potentially by caching only
the "should the folder be hidden" information in the proxy models, but
the current state has a very noticeable performance hit, most notably in
the folder selector used in quick move and copy as well as jump. Since
the memory hit even with huge folder lists is bearable, this seems the
better trade off, for the moment.

M  +3    -3    mailcommon/foldercollection.cpp

http://commits.kde.org/kdepim/3b6e3ade255ca5bdce3e2f143344a935cc6c1559

diff --git a/mailcommon/foldercollection.cpp b/mailcommon/foldercollection.cpp
index 82abd5a..91b3a83 100644
--- a/mailcommon/foldercollection.cpp
+++ b/mailcommon/foldercollection.cpp
@@ -32,19 +32,19 @@ using namespace Akonadi;
 
 #include <QMutex>
 #include <QMutexLocker>
-#include <QWeakPointer>
+#include <QSharedPointer>
 
 namespace MailCommon {
 
 static QMutex mapMutex;
-static QMap<Collection::Id,QWeakPointer<FolderCollection> > fcMap;
+static QMap<Collection::Id,QSharedPointer<FolderCollection> > fcMap;
 
 QSharedPointer<FolderCollection> FolderCollection::forCollection(
   const Akonadi::Collection &coll, bool writeConfig )
 {
   QMutexLocker lock( &mapMutex );
 
-  QSharedPointer<FolderCollection> sptr = fcMap.value( coll.id() ).toStrongRef();
+  QSharedPointer<FolderCollection> sptr = fcMap.value( coll.id() );
 
   if ( !sptr ) {
     sptr = QSharedPointer<FolderCollection>( new FolderCollection( coll, writeConfig ) );
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic