From 11c5c078c7743050a115a4dcc31f52caaa378e35 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 6 Jan 2020 12:11:28 +0100 Subject: Eliminate QLocale's default_number_options global static It had create()'s default number options when passed to create, so wasn't useful then; and otherwise shadowed the value held by the cached private for the default locale. Noticed in the course of adding an analogous global for the system locale. Drive-by - eliminated a redundant language != C check. Change-Id: I5601dc09188804c11dede5be460bfdd12b8152ce Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index e3e0ebdcbd..e3530eeee1 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -651,7 +651,6 @@ int qt_repeatCount(QStringView s) } static const QLocaleData *default_data = nullptr; -static QLocale::NumberOptions default_number_options = QLocale::DefaultNumberOptions; static const QLocaleData *const c_data = locale_data; static QLocalePrivate *c_private() @@ -834,7 +833,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer, defaultLocalePrivate, - (QLocalePrivate::create(defaultData(), default_number_options))) + (QLocalePrivate::create(defaultData()))) Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer, systemLocalePrivate, (QLocalePrivate::create(systemData()))) @@ -862,8 +861,9 @@ static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Sc QLocale::NumberOptions numberOptions = QLocale::DefaultNumberOptions; // If not found, should default to system - if (data->m_language_id == QLocale::C && language != QLocale::C) { - numberOptions = default_number_options; + if (data->m_language_id == QLocale::C) { + if (defaultLocalePrivate.exists()) + numberOptions = defaultLocalePrivate->data()->m_numberOptions; data = defaultData(); } return QLocalePrivate::create(data, offset, numberOptions); @@ -1175,12 +1175,9 @@ QString QLocale::createSeparatedList(const QStringList &list) const void QLocale::setDefault(const QLocale &locale) { default_data = locale.d->m_data; - default_number_options = locale.numberOptions(); - if (defaultLocalePrivate.exists()) { - // update the cached private + if (defaultLocalePrivate.exists()) // update the cached private *defaultLocalePrivate = locale.d; - } } /*! -- cgit v1.2.3