Commit fd5a03f5 authored by Emmanuel Lepage Vallée's avatar Emmanuel Lepage Vallée Committed by Guillaume Roguez

certificateModel: Add a new mutex for the cache insertion

It isn't the same operation as the already protected sections.
The new mutex is specific to m_hCertificates insertions.

Change-Id: Ib178fa216a7dd082aba18b5131b87271b1d0a4e8
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 8b6c02ae
......@@ -629,7 +629,11 @@ Certificate* CertificateModel::getCertificateFromPath(const QString& path, Accou
if (!cert) {
cert = new Certificate(path, Certificate::Type::NONE);
cert->setCollection(m_pFallbackDaemonCollection);
{ // mutex
QMutexLocker(&d_ptr->m_CertInsertion);
d_ptr->m_hCertificates[path.toLatin1()] = cert;
} // mutex
//Add it to the model
d_ptr->addToTree(cert,a);
......@@ -656,7 +660,11 @@ Certificate* CertificateModel::getCertificateFromPath(const QString& path, Certi
if (!cert) {
cert = new Certificate(path, type);
cert->setCollection(m_pFallbackDaemonCollection);
{ // mutex
QMutexLocker(&d_ptr->m_CertInsertion);
d_ptr->m_hCertificates[path.toLatin1()] = cert;
} // mutex
//Add it to the model
d_ptr->addToTree(cert);
......@@ -672,7 +680,11 @@ Certificate* CertificateModel::getCertificateFromId(const QString& id, Account*
//The certificate is not loaded yet
if (!cert) {
cert = new Certificate(id);
{ // mutex
QMutexLocker(&d_ptr->m_CertInsertion);
d_ptr->m_hCertificates[id.toLatin1()] = cert;
} // mutex
if ((!a) && (!category.isEmpty())) {
CertificateNode* cat = d_ptr->m_hStrToCat.value(category);
......
......@@ -57,6 +57,7 @@ public:
QHash<QString,Certificate*> m_hCertificates ;
CertificateNode* m_pDefaultCategory ;
QMutex m_CertLoader ;
QMutex m_CertInsertion ;
int m_GroupCounter ;
QHash<const Account*,CertificateNode*> m_hAccToCat ;
QHash<const QString&,CertificateNode*> m_hStrToCat ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment