Qt 5.6 behavior change with QByteArray(str, size) and QFile::encodeName()
Matthew Dawson
matthew at mjdsystems.ca
Mon Nov 9 00:37:06 UTC 2015
On November 7, 2015 08:07:11 PM David Faure wrote:
> KTar's unittests detected a behavior change in Qt.
> Thiago, is it intentional, or should it be fixed in Qt ?
>
> KTar does
>
> QString name = QFile::decodeName(QByteArray(buffer, 100));
>
> where buffer is e.g. "filename\0\0\0\0\0\0[...]"
>
> With Qt < 5.6 this would lead to name being equal to "filename".
>
> With Qt 5.6 from git, it leads to name being equal to
> "filename\0\0\0\0\0etc.".
>
> It appears that QUtfCodec doesn't stop at the first null byte anymore.
>
> This appears to fix it:
> - name = QFile::decodeName(QByteArray(buffer, 100));
> + name = QFile::decodeName(QByteArray(buffer, qstrnlen(buffer,
> 100)));
>
> but I have to find the other places in there, some more unittests still
> fail.
It appears this was a deliberate change, see https://codereview.qt-project.org/#/c/106473/ . It affects KConfig as well, and I've posted a patch
for its autotests.
--
Matthew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5584 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20151108/0ea4894e/attachment.bin>
More information about the Kde-frameworks-devel
mailing list