Skip to content
Snippets Groups Projects
Commit 815d3241 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

contactmodel: move profile creation on dedicated thread

This avoid a heavy I/O operation on the main pool

Change-Id: Ic5068d9d1c291b8f27ffc563933d4920af42e890
GitLab: #1450
parent 2343f34b
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "api/contactmodel.h" #include "api/contactmodel.h"
#include <QThreadPool>
// LRC // LRC
#include "api/account.h" #include "api/account.h"
#include "api/contact.h" #include "api/contact.h"
...@@ -121,6 +123,8 @@ public: ...@@ -121,6 +123,8 @@ public:
QString searchStatus_ {}; QString searchStatus_ {};
QMap<QString, QString> nonContactLookup_; QMap<QString, QString> nonContactLookup_;
QThreadPool profileThreadPool;
public Q_SLOTS: public Q_SLOTS:
/** /**
* Listen CallbacksHandler when a presence update occurs * Listen CallbacksHandler when a presence update occurs
...@@ -690,6 +694,7 @@ ContactModelPimpl::~ContactModelPimpl() ...@@ -690,6 +694,7 @@ ContactModelPimpl::~ContactModelPimpl()
&ConfigurationManagerInterface::userSearchEnded, &ConfigurationManagerInterface::userSearchEnded,
this, this,
&ContactModelPimpl::slotUserSearchEnded); &ContactModelPimpl::slotUserSearchEnded);
profileThreadPool.waitForDone();
} }
bool bool
...@@ -1196,6 +1201,7 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, ...@@ -1196,6 +1201,7 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId,
if (accountId != linked.owner.id) if (accountId != linked.owner.id)
return; return;
profileThreadPool.start([=] {
QFile vCardFile(path); QFile vCardFile(path);
if (!vCardFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!vCardFile.open(QIODevice::ReadOnly | QIODevice::Text))
return; return;
...@@ -1234,6 +1240,7 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, ...@@ -1234,6 +1240,7 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId,
linked.owner.contactModel->addContact(contactInfo); linked.owner.contactModel->addContact(contactInfo);
contactInfo.profileInfo.avatar.clear(); // Do not store after update contactInfo.profileInfo.avatar.clear(); // Do not store after update
});
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment