From 6c60117d0140e5b70ced78f4dc246ed285273f8c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 10 Nov 2023 22:19:15 +0100 Subject: [PATCH] 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 --- tests/auto/corelib/text/qstring/tst_qstring.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 92b4a266404..b31c5dedb8b 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -351,7 +351,8 @@ private: 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: TransientDefaultLocale(const QLocale &transient) { revise(transient); } void revise(const QLocale &transient) { QLocale::setDefault(transient); }