[Development] [RFO QTBUG-84739] QJsonValue::fromVariant containing QByteArray
tomz at freedommail.ch
Thu Jul 2 18:57:53 CEST 2020
Thank you all for discussing this, and Thiago for bringing this up here.
I was one of the people that got hit with this behavior change and I want to
talk about this with a more human approach.
The basic point is that developers have been adding a bytearray as a string,
which gives them the string in the JSON. This worked, hence existing code did
this with the intention of getting a string. Because thats what they got.
Now, it looks like we are concluding that using a bytearray should likely
never be done by the developer here because Qt is forced to convert this to
UTF-8 text, encoding errors are waiting. Magic happens, people should avoid
Bottom line, for Qt6 it would be nice to somehow tell people to not do this.
Enforcing it would be even better.. somehow. (fail-fast is something I like).
I agree with Jason H that converting a byte-array to anything but
QString::fromUtf8() is almost just as non-sensical as converting it to a
string. For practically the same reason: its magic that happens. It breaks the
rule of least surprise.
Today's question, though, is about what to do with 15.1. And I think that the
majority of deployments tend to skip dot zero releases. Not so much because
they dislike dot zero's, but mostly due to inertia. Companies, Linux distros,
lazy developers, etc. They don't update every week, its holidays anyway, so
the chance that apps actually broke in deployemnt, due to this behavior chance
is much mitigated.
On the other hand, the chance of people running ANY Qt5 code at one point in
the future on top of the 5.15 series is lim(100)%. Because this is the LTS
release, because Qt6 is going to break stuff and the 5.15 hides a chasm that
apps can only cross when held by a developer.
So, purely from the "least pain" perspective I'd argue that doing a revert of
the behavior chance in 5.15.1 is the way to go. This will end up with the
least impact to the world-wide ecosystem, over the next year or 2.
Because as time goes on, a lot of apps and many distros will ship non-ported
Qt5 apps which will be linked against 5.15. Apps that may not have a
maintainer, apps that run on Car OSs which doesn't want to include two Qt
releases. You get my point. Inertia.
So lets wait with the behavior change until Qt6 and revert the behavior change
in 5.15.0 again in 5.15.1 to print the string.
All IMOHO. My app has stopped using a QBytearray already :)
Tom Zander, C++ dev.
More information about the Development