Go to file
Edward Welbourne 6c5dac1685 Fix handling of DateTime values in QSettings
Since 5.6.0, Qt's serialization of QDateTime in QSettings files has
had special-case handling to use a newer QDataStream version than the
one QSettings uses for most other types. This was handled in the
serialization and parsing, but not taken into account in the code that
turned binary data into content suitable for saving to an ini file.

In Qt 5 this caused no problem when no iniCodec was set on the
QSettings object but Qt 6 now uses UTF-8 as (in effect) codec on every
QSettings object. This lead to the binary data encoding QDateTime
being encoded as if it were Unicode, instead of using \x tokens where
suitable. This lead to an unintended incompatible change in how
QSettings stores QDateTime values: Qt 6 was still able to read Qt 5's
values, but Qt 5 was unable to read Qt 6's settings files (unless it
sets its iniCodec to UTF-8, which works round the problem).

The code to convert raw binary data to ini-file-friendly value texts
had a special case for ByteArray and Variant values, to ignore the
codec and use \x tokens: when support for QDateTime was split from
Variant, it gained a DateTime prefix in the parsing code that wasn't
included in this special handling. So add that now.

The resulting DateTime values now match Qt 5 so are readable by it and
by Qt 6 (including versions prior to this change); and the code to
read a DateTime can still read what earlier Qt 6 versions have been
writing. It is likely a Qt 5 QSettings with an iniCodec other than
UTF-8 may have problems with the result, but that was already true.

This amends commit 73b8cd879c

Fixes: QTBUG-102334
Pick-to: 6.2 6.3 5.15
Change-Id: Icc44a33db3dcc6400144bc001710b400ee883c90
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-04-21 23:05:47 +02:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Provide a qtpaths wrapper script when cross-building Qt 2021-11-08 13:41:03 +01:00
cmake wasm: add specialHTMLTargets to EXPORTED_RUNTIME_METHODS for qmake 2022-04-21 13:00:57 +10:00
coin CI: add Windows host support for QNX 2022-04-05 17:03:40 +03:00
config.tests CMake: Make sure the strip_for_binary project works with Makefiles 2022-04-04 15:41:20 +02:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Add a marker for post-C++17 APIs in exported classes 2022-04-11 23:26:00 +02:00
examples Replace uses of _qs with _s in sources and examples 2022-04-19 19:12:20 +02:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec CMake: Pass -v to ninja when using ctest --build-and-test 2022-04-04 15:41:20 +02:00
mkspecs wasm: add specialHTMLTargets to EXPORTED_RUNTIME_METHODS for qmake 2022-04-21 13:00:57 +10:00
qmake Replace uses of _qs with _s in sources and examples 2022-04-19 19:12:20 +02:00
src Fix handling of DateTime values in QSettings 2022-04-21 23:05:47 +02:00
tests Add support for unwrapping QFuture<QFuture<T>> 2022-04-21 20:25:13 +00:00
util Remove the qmake2cmake wrapper scripts and document where they are 2022-04-12 10:34:40 +02:00
.cmake.conf cmake: only use qtbase configuration in qtbase 2022-03-18 12:33:10 +01:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Assume qhelpgenerator in libexec instead of bin 2021-11-08 19:27:32 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
CMakeLists.txt Use REALPATH based check for symbolic links on Windows 2022-01-07 14:31:38 +01:00
conanfile.py Conan: Resolve the 'qt_host_path' before assigning it to 'QT_HOST_PATH' env 2022-04-06 17:46:59 +03:00
config_help.txt Build system: Allow user to enable Intel CET 2022-04-06 13:06:24 +08:00
configure Remove unsupported, host-related options from configure shell script 2021-08-05 02:44:27 +02:00
configure.bat configure.bat: Fix call without arguments 2022-02-16 12:05:48 +01:00
configure.cmake CMake: Fix no_prefix feature to take into account the staging prefix 2022-04-19 17:20:14 +02:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
LICENSE.FDL Remove trailing whitespace in LICENSE.FDL 2021-11-26 18:28:49 +01:00
LICENSE.GPL2 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3-EXCEPT Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.QT-LICENSE-AGREEMENT Update LA 4.4.1 2022-03-25 20:07:30 +00:00
qt_cmdline.cmake Build system: Allow user to enable Intel CET 2022-04-06 13:06:24 +08:00
sync.profile QVariant: reduce transitive includes 2022-03-17 16:14:38 +00:00