summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qlocale.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 57f9b22e53..991cc9e170 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -708,6 +708,9 @@ const QLocaleData *QLocalePrivate::dataPointerForIndex(quint16 index)
return &locale_data[index];
}
+Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate,
+ (QLocalePrivate::create(defaultData(), default_number_options)))
+
static QLocalePrivate *localePrivateByName(const QString &name)
{
if (name == QLatin1String("C"))
@@ -715,11 +718,6 @@ static QLocalePrivate *localePrivateByName(const QString &name)
return QLocalePrivate::create(findLocaleData(name));
}
-static QLocalePrivate *defaultLocalePrivate()
-{
- return QLocalePrivate::create(defaultData(), default_number_options);
-}
-
static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Script script,
QLocale::Country country)
{
@@ -790,7 +788,7 @@ QLocale::QLocale(const QString &name)
*/
QLocale::QLocale()
- : d(defaultLocalePrivate())
+ : d(*defaultLocalePrivate)
{
}
@@ -1002,6 +1000,11 @@ void QLocale::setDefault(const QLocale &locale)
{
default_data = locale.d->m_data;
default_number_options = locale.numberOptions();
+
+ if (defaultLocalePrivate.exists()) {
+ // update the cached private
+ *defaultLocalePrivate = locale.d;
+ }
}
/*!