diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-04-25 22:28:13 -0700 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-07-30 15:04:14 +0000 |
commit | 5da8e5ddd424a11435a3750dc9b955295aeaed9c (patch) | |
tree | 82c1dd5fe0fd5fe4ea8ee9dd11a65d49b261dfe5 /src/corelib | |
parent | 941184bd642c9627c85c5618c2168cefa7787b0e (diff) |
QLocale: cache the QLocalePrivate for QLocale::system()
Change-Id: I6d0bf78d02d166307f864f1f83a3b600ef6a9b0b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index d2254f5884..36e2dd52bf 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -661,6 +661,7 @@ static const QSystemLocale *systemLocale() void QLocalePrivate::updateSystemPrivate() { + // this function is NOT thread-safe! const QSystemLocale *sys_locale = systemLocale(); if (!system_data) system_data = &globalLocaleData; @@ -785,6 +786,8 @@ static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate, (QLocalePrivate::create(defaultData(), default_number_options))) +Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, systemLocalePrivate, + (QLocalePrivate::create(systemData()))) static QLocalePrivate *localePrivateByName(const QString &name) { @@ -2343,7 +2346,9 @@ QString QLocale::toString(double i, char f, int prec) const QLocale QLocale::system() { - return QLocale(*QLocalePrivate::create(systemData())); + // this function is NOT thread-safe! + QT_PREPEND_NAMESPACE(systemData)(); // trigger updating of the system data if necessary + return QLocale(*systemLocalePrivate->data()); } |