summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-07 10:16:04 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-10-07 16:24:57 (GMT)
commit5a5a4368fdd984aeaf830e6a3af3584fa84838f7 (patch)
tree1e9bdeb0ef19a59c18d3cb085f3c52be149dcc21
parentcf07c93a83a64be1590b6bdddb46f7cafb6fcf05 (diff)
downloadQt-5a5a4368fdd984aeaf830e6a3af3584fa84838f7.zip
Qt-5a5a4368fdd984aeaf830e6a3af3584fa84838f7.tar.gz
Qt-5a5a4368fdd984aeaf830e6a3af3584fa84838f7.tar.bz2
Fixed initialization of the system locale on Symbian.
Made it thread-safe and actually make sure that we don't initialize the data several times. Reviewed-by: axis (cherry picked from commit 0418d438d1c1acfe2c95ee748c1e7c84a0ee8837)
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
index 931fbb4..1660e95 100644
--- a/src/corelib/tools/qlocale_symbian.cpp
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -43,6 +43,7 @@
#include <QLocale>
#include <QTime>
#include <QVariant>
+#include <QThread>
#include <e32std.h>
#include "private/qcore_symbian_p.h"
@@ -773,8 +774,8 @@ static QLocale::MeasurementSystem symbianMeasurementSystem()
QLocale QSystemLocale::fallbackLocale() const
{
// load system data before query calls
- static bool initDone = false;
- if (!initDone) {
+ static QBasicAtomicInt initDone = Q_BASIC_ATOMIC_INITIALIZER(0);
+ if (initDone.testAndSetRelaxed(0, 1)) {
_s60Locale.LoadSystemSettings();
// Initialize platform version dependent function pointers
@@ -794,7 +795,12 @@ QLocale QSystemLocale::fallbackLocale() const
ptrGetLongDateFormatSpec = &defaultFormatSpec;
if (!ptrGetShortDateFormatSpec)
ptrGetShortDateFormatSpec = &defaultFormatSpec;
+ bool ret = initDone.testAndSetRelease(1, 2);
+ Q_ASSERT(ret);
+ Q_UNUSED(ret);
}
+ while(initDone != 2)
+ QThread::yieldCurrentThread();
TLanguage lang = User::Language();
QString locale = QLatin1String(qt_symbianLocaleName(lang));