diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-27 11:26:37 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-27 11:26:37 +0100 |
commit | 96c7daa17f7db316419302c5bca7c3258c5a772b (patch) | |
tree | 34be8ef04ede93ebf899b68cd0908946d687ca5c | |
parent | 2b012938ac0adaa173705c931e12f40184036183 (diff) | |
download | sink-96c7daa17f7db316419302c5bca7c3258c5a772b.tar.gz sink-96c7daa17f7db316419302c5bca7c3258c5a772b.zip |
Ensure the initialization of the TypeIndex is threadsafe.
Multiple initial queries can be running at the same time.
-rw-r--r-- | common/domain/event.cpp | 5 | ||||
-rw-r--r-- | common/domain/folder.cpp | 5 | ||||
-rw-r--r-- | common/domain/mail.cpp | 5 |
3 files changed, 15 insertions, 0 deletions
diff --git a/common/domain/event.cpp b/common/domain/event.cpp index a348e65..18009fc 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <QVector> | 21 | #include <QVector> |
22 | #include <QByteArray> | 22 | #include <QByteArray> |
23 | #include <QString> | 23 | #include <QString> |
24 | #include <QMutex> | ||
25 | #include <QMutexLocker> | ||
24 | 26 | ||
25 | #include "../resultset.h" | 27 | #include "../resultset.h" |
26 | #include "../index.h" | 28 | #include "../index.h" |
@@ -33,10 +35,13 @@ | |||
33 | 35 | ||
34 | #include "event_generated.h" | 36 | #include "event_generated.h" |
35 | 37 | ||
38 | static QMutex sMutex; | ||
39 | |||
36 | using namespace Akonadi2::ApplicationDomain; | 40 | using namespace Akonadi2::ApplicationDomain; |
37 | 41 | ||
38 | static TypeIndex &getIndex() | 42 | static TypeIndex &getIndex() |
39 | { | 43 | { |
44 | QMutexLocker locker(&sMutex); | ||
40 | static TypeIndex *index = 0; | 45 | static TypeIndex *index = 0; |
41 | if (!index) { | 46 | if (!index) { |
42 | index = new TypeIndex("event"); | 47 | index = new TypeIndex("event"); |
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index 3cd221e..7934841 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <QVector> | 21 | #include <QVector> |
22 | #include <QByteArray> | 22 | #include <QByteArray> |
23 | #include <QString> | 23 | #include <QString> |
24 | #include <QMutex> | ||
25 | #include <QMutexLocker> | ||
24 | 26 | ||
25 | #include "../resultset.h" | 27 | #include "../resultset.h" |
26 | #include "../index.h" | 28 | #include "../index.h" |
@@ -33,10 +35,13 @@ | |||
33 | 35 | ||
34 | #include "folder_generated.h" | 36 | #include "folder_generated.h" |
35 | 37 | ||
38 | static QMutex sMutex; | ||
39 | |||
36 | using namespace Akonadi2::ApplicationDomain; | 40 | using namespace Akonadi2::ApplicationDomain; |
37 | 41 | ||
38 | static TypeIndex &getIndex() | 42 | static TypeIndex &getIndex() |
39 | { | 43 | { |
44 | QMutexLocker locker(&sMutex); | ||
40 | static TypeIndex *index = 0; | 45 | static TypeIndex *index = 0; |
41 | if (!index) { | 46 | if (!index) { |
42 | index = new TypeIndex("folder"); | 47 | index = new TypeIndex("folder"); |
diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index a698b6d..8875d88 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <QVector> | 21 | #include <QVector> |
22 | #include <QByteArray> | 22 | #include <QByteArray> |
23 | #include <QString> | 23 | #include <QString> |
24 | #include <QMutex> | ||
25 | #include <QMutexLocker> | ||
24 | 26 | ||
25 | #include "../resultset.h" | 27 | #include "../resultset.h" |
26 | #include "../index.h" | 28 | #include "../index.h" |
@@ -33,10 +35,13 @@ | |||
33 | 35 | ||
34 | #include "mail_generated.h" | 36 | #include "mail_generated.h" |
35 | 37 | ||
38 | static QMutex sMutex; | ||
39 | |||
36 | using namespace Akonadi2::ApplicationDomain; | 40 | using namespace Akonadi2::ApplicationDomain; |
37 | 41 | ||
38 | static TypeIndex &getIndex() | 42 | static TypeIndex &getIndex() |
39 | { | 43 | { |
44 | QMutexLocker locker(&sMutex); | ||
40 | static TypeIndex *index = 0; | 45 | static TypeIndex *index = 0; |
41 | if (!index) { | 46 | if (!index) { |
42 | index = new TypeIndex("mail"); | 47 | index = new TypeIndex("mail"); |