Skip to content
Snippets Groups Projects
Commit fd5a03f5 authored by Emmanuel Lepage Vallée's avatar Emmanuel Lepage Vallée Committed by Guillaume Roguez
Browse files

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: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 8b6c02ae
Branches
No related tags found
No related merge requests found
...@@ -629,7 +629,11 @@ Certificate* CertificateModel::getCertificateFromPath(const QString& path, Accou ...@@ -629,7 +629,11 @@ Certificate* CertificateModel::getCertificateFromPath(const QString& path, Accou
if (!cert) { if (!cert) {
cert = new Certificate(path, Certificate::Type::NONE); cert = new Certificate(path, Certificate::Type::NONE);
cert->setCollection(m_pFallbackDaemonCollection); cert->setCollection(m_pFallbackDaemonCollection);
{ // mutex
QMutexLocker(&d_ptr->m_CertInsertion);
d_ptr->m_hCertificates[path.toLatin1()] = cert; d_ptr->m_hCertificates[path.toLatin1()] = cert;
} // mutex
//Add it to the model //Add it to the model
d_ptr->addToTree(cert,a); d_ptr->addToTree(cert,a);
...@@ -656,7 +660,11 @@ Certificate* CertificateModel::getCertificateFromPath(const QString& path, Certi ...@@ -656,7 +660,11 @@ Certificate* CertificateModel::getCertificateFromPath(const QString& path, Certi
if (!cert) { if (!cert) {
cert = new Certificate(path, type); cert = new Certificate(path, type);
cert->setCollection(m_pFallbackDaemonCollection); cert->setCollection(m_pFallbackDaemonCollection);
{ // mutex
QMutexLocker(&d_ptr->m_CertInsertion);
d_ptr->m_hCertificates[path.toLatin1()] = cert; d_ptr->m_hCertificates[path.toLatin1()] = cert;
} // mutex
//Add it to the model //Add it to the model
d_ptr->addToTree(cert); d_ptr->addToTree(cert);
...@@ -672,7 +680,11 @@ Certificate* CertificateModel::getCertificateFromId(const QString& id, Account* ...@@ -672,7 +680,11 @@ Certificate* CertificateModel::getCertificateFromId(const QString& id, Account*
//The certificate is not loaded yet //The certificate is not loaded yet
if (!cert) { if (!cert) {
cert = new Certificate(id); cert = new Certificate(id);
{ // mutex
QMutexLocker(&d_ptr->m_CertInsertion);
d_ptr->m_hCertificates[id.toLatin1()] = cert; d_ptr->m_hCertificates[id.toLatin1()] = cert;
} // mutex
if ((!a) && (!category.isEmpty())) { if ((!a) && (!category.isEmpty())) {
CertificateNode* cat = d_ptr->m_hStrToCat.value(category); CertificateNode* cat = d_ptr->m_hStrToCat.value(category);
......
...@@ -57,6 +57,7 @@ public: ...@@ -57,6 +57,7 @@ public:
QHash<QString,Certificate*> m_hCertificates ; QHash<QString,Certificate*> m_hCertificates ;
CertificateNode* m_pDefaultCategory ; CertificateNode* m_pDefaultCategory ;
QMutex m_CertLoader ; QMutex m_CertLoader ;
QMutex m_CertInsertion ;
int m_GroupCounter ; int m_GroupCounter ;
QHash<const Account*,CertificateNode*> m_hAccToCat ; QHash<const Account*,CertificateNode*> m_hAccToCat ;
QHash<const QString&,CertificateNode*> m_hStrToCat ; QHash<const QString&,CertificateNode*> m_hStrToCat ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment