diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-05-28 13:29:52 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-06-05 12:12:36 +0200 |
commit | c7420d9cb8e15d1f094fa92cfab635a86246c670 (patch) | |
tree | 8be8bd9e856b3294bbb8fa1e5e60bb7566be40a1 /src/corelib/text/qlocale.cpp | |
parent | ee8ba0e0ca0bbcc2e6f15b12244259b2d800f498 (diff) |
Create QLocale's default store if missing when setDefault() is called
A check to prevent crash-on-exit if QLocale::setDefault() was called
after the default store was torn down had the side-effect of causing
setDefault() to not record data if it was called before the first
access to the default store caused it to come into being.
Change the check to test that the default store has been destroyed
and, if not, create it if it doesn't exist yet. This refines commit
4d6572aac0eb1f75f3c810ce8e92635b956d29fc (as modified by commit
11c5c078c7743050a115a4dcc31f52caaa378e35).
Fixes: QTBUG-83016
Fixes: QTBUG-83415
Pick-to: 5.15
Change-Id: Icbce9bd9c75d0258d403e2f90957561b5a18bdf3
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r-- | src/corelib/text/qlocale.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 46f3a5bb05..e31b5c9155 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1225,8 +1225,16 @@ void QLocale::setDefault(const QLocale &locale) { default_data = locale.d->m_data; - if (defaultLocalePrivate.exists()) // update the cached private - *defaultLocalePrivate = locale.d; + if (defaultLocalePrivate.isDestroyed()) + return; // avoid crash on exit + if (!defaultLocalePrivate.exists()) { + // Force it to exist; see QTBUG-83016 + QLocale ignoreme; + Q_ASSERT(defaultLocalePrivate.exists()); + } + + // update the cached private + *defaultLocalePrivate = locale.d; } /*! |