Skip to content

Commit

Permalink
Eliminate QSystemLocaleSingleton and QSystemLocale(bool)
Browse files Browse the repository at this point in the history
They are no longer needed. The global static will only ever be
instantiated if and when the QSystemLocale stack is empty; it will
then survive to the end of run-time, serving as a bottom-of-stack
instance that will always be fallen back to after any other instances'
lifetimes. It can thus be a local static of the only function that
accesses it.

Change-Id: I21a1623728b25b46da6e25db9bb973c507a39ca3
Reviewed-by: Thiago Macieira <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
  • Loading branch information
ediosyncratic committed Sep 7, 2022
1 parent 6a14ad4 commit 21d4e3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
20 changes: 6 additions & 14 deletions src/corelib/text/qlocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ using namespace Qt::StringLiterals;

#ifndef QT_NO_SYSTEMLOCALE
Q_CONSTINIT static QSystemLocale *_systemLocale = nullptr;
class QSystemLocaleSingleton: public QSystemLocale
{
public:
QSystemLocaleSingleton() : QSystemLocale(true) {}
};

Q_GLOBAL_STATIC(QSystemLocaleSingleton, QSystemLocale_globalSystemLocale)
Q_CONSTINIT static QLocaleData systemLocaleData = {};
#endif

Expand Down Expand Up @@ -721,12 +714,6 @@ QSystemLocale::QSystemLocale() : next(_systemLocale)
systemLocaleData.m_language_id = 0;
}

/*!
\internal
*/
QSystemLocale::QSystemLocale(bool)
{ }

/*!
\internal
Deletes the object.
Expand All @@ -750,7 +737,12 @@ static const QSystemLocale *systemLocale()
{
if (_systemLocale)
return _systemLocale;
return QSystemLocale_globalSystemLocale();

// As this is only ever instantiated with _systemLocale null, it is
// necessarily the ->next-most in any chain that may subsequently develop;
// and it won't be destructed until exit()-time.
static QSystemLocale globalInstance;
return &globalInstance;
}

static void updateSystemPrivate()
Expand Down
3 changes: 0 additions & 3 deletions src/corelib/text/qlocale_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ class Q_CORE_EXPORT QSystemLocale

virtual QLocale fallbackLocale() const;
inline qsizetype fallbackLocaleIndex() const;
private:
QSystemLocale(bool);
friend class QSystemLocaleSingleton;
};
Q_DECLARE_TYPEINFO(QSystemLocale::QueryType, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QSystemLocale::CurrencyToStringArgument, Q_RELOCATABLE_TYPE);
Expand Down

0 comments on commit 21d4e3a

Please sign in to comment.