From 78e92997ed35ddc8bb6f7f6c0a4fffba026d5d8f Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 2 Jan 2018 10:48:34 +0100 Subject: QLocale: Update the system private on QLocale default constructor if needed When first starting an Android app we have invocation order issue, to load the platform plugin we create the default QLocale (needed by the resource locator code to see if :/qt/etc/qt.conf exists) so when the android platform plugin loads and creates its own QSystemLocale, the QLocale defaultLocalePrivate is already created and pointing to globalLocaleData which means that systemData won't be called and thus the code that triggers the call to QLocalePrivate::updateSystemPrivate won't be called when calling QLocale(). I thought of two ways of fixing this, one was calling QLocalePrivate::updateSystemPrivatea() from the QAndroidSystemLocale constructor, but giving the responsibility to not break things to the plugin seems a little fragile, so making the check on QLocale() seems better. Without this patch an Android app doing QApplication app(argc, argv); qDebug() << QLocale().name(); qDebug() << QLocale().name(); qDebug() << QLocale::system().name(); qDebug() << QLocale().name(); would print "" "" "ca_ES" "ca_ES" now it correctly prints "ca_ES" the four times. Task-number: QTBUG-41385 Change-Id: I2cf419f59aa008fa3aca11295fe7d42c40bcc32e Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- src/corelib/tools/qlocale.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index f7a6f35183..09b148ea9e 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -852,6 +852,8 @@ QLocale::QLocale(const QString &name) QLocale::QLocale() : d(*defaultLocalePrivate) { + // Make sure system data is up to date + systemData(); } /*! -- cgit v1.2.3