tst_QString: explain TransientDefaultLocale better

A default-constructed QLocale gets initialized with the
currently-active default locale, and apparently retains that setting
henceforth. That is why the `prior` member is not explicitly
initialized, which is confusing at face value.

Explain the mechanism better, and explicitly default-initialize the
member, so the next reader of the code saves the time to research
this.

Amends 76dfda1ad12cc42cdd832aed1edbe5f76b0cbb2d.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I1d1171f8564c70a971938b92b809f63ba5637d3a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Marc Mutz 2023-11-10 22:19:15 +01:00
parent f395934419
commit 6c60117d01

View File

@ -351,7 +351,8 @@ private:
class TransientDefaultLocale class TransientDefaultLocale
{ {
const QLocale prior; // Records what *was* the default before we set it. // This default-constructed QLocale records what *was* the default before we changed it:
const QLocale prior = {};
public: public:
TransientDefaultLocale(const QLocale &transient) { revise(transient); } TransientDefaultLocale(const QLocale &transient) { revise(transient); }
void revise(const QLocale &transient) { QLocale::setDefault(transient); } void revise(const QLocale &transient) { QLocale::setDefault(transient); }