2e9d33e534
Nothing prevents client code from calling QLocale::setDefault() before we ever instantiate QLocale::system() - aside from some quirks that mean setDefault(), currently, does instantiate QLocale::system() to force initialization of defaultLocalePrivate - so using defaultIndex() could set the system QLocalePrivate instance's index incorrectly. In any case, even if the index is initially set correctly, a subsequent change to the system locale would change the correct index; and nothing outside QLocale::system() has access to the instance that would then be remembering an out-of-date index. Actually tripping over that inconsistency took some deviousness, but was possible. The index is (currently) only used for month name lookups and those special-case, for the Roman-derived calendars, the system locale, to only use the index if the system locale offers no name for a month. Meanwhile, updateSystemPrivate() uses the fallback locale's index for its look-up of which CLDR data to copy into the fallback QLocaleData for the system locale. None the less, a non-Roman calendar's lookup will go via the index to get at the CLDR data for that calendar, thereby exposing the system locale's index to use; and, sure enough, a setDefault() could lead that to produce wrong answers. In QLocale::system() there's a cached QLocalePrivate, whose index we need to ensure stays in sync with the active system locale. So pass its &m_index to systemData(), which will now (when passed this) ensure it's up to date. Since we always have called systemData(), to ensure it is up to date, we can skip that update in the initialization of the cached private and use m_index = -1 to let systemData() know when it's in the initial call, thereby making the static cache constinit. Amended a test to what proved the issue was present. Change-Id: I8d7ab5830cf0bbb9265c2af2a1edc9396ddef79f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> |
||
---|---|---|
.. | ||
auto | ||
baseline | ||
benchmarks | ||
global | ||
libfuzzer | ||
manual | ||
shared | ||
testserver | ||
CMakeLists.txt | ||
README |
This directory contains autotests and benchmarks based on Qt Test. In order to run the autotests reliably, you need to configure a desktop to match the test environment that these tests are written for. Linux X11: * The user must be logged in to an active desktop; you can't run the autotests without a valid DISPLAY that allows X11 connections. * The tests are run against a KDE3 or KDE4 desktop. * Window manager uses "click to focus", and not "focus follows mouse". Many tests move the mouse cursor around and expect this to not affect focus and activation. * Disable "click to activate", i.e., when a window is opened, the window manager should automatically activate it (give it input focus) and not wait for the user to click the window.