[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:08:43 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=836555c

The following commit has been merged in the master branch:
commit 836555ca47ad19ed33cf156506a8c0a1cdc1b12f
Author: Aleix Pol <aleixpol at kde.org>
Date:   Fri Feb 13 00:21:17 2015 +0100

    Re-use AbstractContacts generated in the KTp KPeople Data Source
    
    Re-use the instances instead of creating them every time the cache is
    loaded.
    
    REVIEW: 122543
---
 kpeople/datasourceplugin/im-persons-data-source.cpp | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/kpeople/datasourceplugin/im-persons-data-source.cpp b/kpeople/datasourceplugin/im-persons-data-source.cpp
index 77cb67f..606ad41 100644
--- a/kpeople/datasourceplugin/im-persons-data-source.cpp
+++ b/kpeople/datasourceplugin/im-persons-data-source.cpp
@@ -168,11 +168,23 @@ void KTpAllContacts::loadCache(const QString &accountId)
     }
 
     while (query.next()) {
-        QExplicitlySharedDataPointer<TelepathyContact> addressee(new TelepathyContact);
 
         const QString accountId =  query.value(0).toString();
         const QString contactId =  query.value(1).toString();
         QString avatarFileName = query.value(3).toString();
+
+        const QString uri = QLatin1String("ktp://") + accountId + QLatin1Char('?') + contactId;
+        QExplicitlySharedDataPointer<TelepathyContact> addressee;
+        bool found = false;
+        {
+            QMap<QString, AbstractContact::Ptr>::const_iterator it = m_contactVCards.constFind(uri);
+            found = it!=m_contactVCards.constEnd();
+            if (found)
+                addressee = QExplicitlySharedDataPointer<TelepathyContact>(static_cast<TelepathyContact*>(it->data()));
+            else
+                addressee = QExplicitlySharedDataPointer<TelepathyContact>(new TelepathyContact);
+        }
+
         addressee->insertProperty(AbstractContact::NameProperty, query.value(2).toString());
 
         if (avatarFileName.isEmpty()) {
@@ -211,12 +223,9 @@ void KTpAllContacts::loadCache(const QString &accountId)
         addressee->insertProperty(S_KPEOPLE_PROPERTY_ACCOUNT_PATH, TP_QT_ACCOUNT_OBJECT_PATH_BASE + QLatin1Char('/') + accountId);
         addressee->insertProperty(S_KPEOPLE_PROPERTY_PRESENCE, s_presenceStrings[Tp::ConnectionPresenceTypeOffline]);
 
-        const QString uri = QLatin1String("ktp://") + accountId + QLatin1Char('?') + contactId;
-
         addressee->insertProperty(S_KPEOPLE_PROPERTY_CONTACT_URI, uri);
 
-        QMap<QString, AbstractContact::Ptr>::const_iterator it = m_contactVCards.constFind(uri);
-        if (it != m_contactVCards.constEnd()) {
+        if (found) {
             Q_EMIT contactChanged(uri, addressee);
         } else {
             Q_EMIT contactAdded(uri, addressee);

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list