qt5base-lts/tests/auto
Tor Arne Vestbø ab0ba66864 Apple OS: Handle QSetting strings with embedded zero-bytes
Saving strings with embedded zero-bytes (\0) as CFStrings would
sometimes fail, and only write the part of the string leading
up to the first zero-byte, instead of all the way to the final
zero-terminator. This bug was revealed by the code-path that
falls back to storing e.g. QTime as strings, via the helper
method QSettingsPrivate::variantToString().

We now use the same approach as on platforms such as Windows
and WinRT, where the string produced by variantToString() is
checked for null-bytes, and if so, stored using a binary
representation instead of as a string. For our case that
means we fall back to CFData when detecting the null-byte.

To separate strings from regular byte arrays, new logic has
been added to variantToString() that wraps the null-byte
strings in @String(). That way we can implement a fast-path
when converting back from CFData, that doesn't go via the
slow and lossy conversion via UTF8, and the resulting QVariant
will be of type QVariant::ByteArray. The reason for using
UTF-8 as the binary representation of the string is that
in the case of storing a QByteArray("@foo") we need to
still be able to convert it back to the same byte array,
which doesn't work if the on-disk format is UTF-16.

Task-number: QTBUG-56124
Change-Id: Iab2f71cf96cf3225de48dc5e71870d74b6dde1e8
Cherry-picked: 764f5bf48c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2016-10-21 09:30:43 +00:00
..
android Updated license headers 2016-01-21 18:55:18 +00:00
bic/data BIC data files for QtBase for Qt 5.7 2016-10-03 09:38:59 +00:00
cmake Merge remote-tracking branch 'origin/5.6' into 5.7 2016-04-04 08:59:18 +02:00
compilerwarnings/data Updated license headers 2016-01-21 18:55:18 +00:00
concurrent Merge remote-tracking branch 'origin/5.6' into 5.7 2016-08-25 16:12:11 +02:00
corelib Apple OS: Handle QSetting strings with embedded zero-bytes 2016-10-21 09:30:43 +00:00
dbus Merge remote-tracking branch 'origin/5.6' into 5.7 2016-06-10 23:27:10 +02:00
gui Merge remote-tracking branch 'origin/5.6' into 5.7 2016-10-01 22:15:55 +02:00
guiapplauncher Fix path to examples part of tst_GuiAppLauncher 2015-02-13 07:28:15 +00:00
installed_cmake Add a unit test for testing Qt in its install location. 2013-07-02 23:08:54 +02:00
network Merge remote-tracking branch 'origin/5.6' into 5.7 2016-10-05 19:33:26 +02:00
opengl Merge remote-tracking branch 'origin/5.6.1' into 5.6 2016-06-02 06:01:25 +02:00
other Merge remote-tracking branch 'origin/5.6' into 5.7 2016-09-28 11:51:35 +02:00
printsupport Merge remote-tracking branch 'origin/5.6' into 5.7 2016-02-29 12:34:31 +01:00
shared Updated license headers 2016-01-21 18:55:18 +00:00
sql Merge remote-tracking branch 'origin/5.6' into 5.7 2016-09-16 23:16:25 +02:00
testlib Blacklist selftest runSubTest 2016-09-12 12:59:48 +00:00
tools Merge remote-tracking branch 'origin/5.6' into 5.7 2016-09-05 13:57:12 +02:00
widgets Merge remote-tracking branch 'origin/5.6' into 5.7 2016-10-05 19:33:26 +02:00
xml Merge remote-tracking branch 'origin/5.6' into 5.7 2016-09-23 22:28:33 +02:00
auto.pro Merge remote-tracking branch 'origin/5.6' into 5.7 2016-04-04 08:59:18 +02:00
network-settings.h Merge remote-tracking branch 'origin/5.6' into 5.7 2016-05-06 15:36:44 +02:00
qtest-config.h Updated license headers 2016-01-21 18:55:18 +00:00
test.pl Updated license headers 2016-01-21 18:55:18 +00:00