[Development] [RFO QTBUG-84739] QJsonValue::fromVariant containing QByteArray

Thiago Macieira thiago.macieira at intel.com
Thu Jul 2 19:04:47 CEST 2020


On Thursday, 2 July 2020 02:12:32 PDT Mathias Hasselmann wrote:
> Am 01.07.2020 um 23:21 schrieb Thiago Macieira:
> > Re: https://bugreports.qt.io/browse/QTBUG-84739
> > Summary: Qt 5.15 has an unintentional change in behaviour that has broken
> > 
> > existing applications. We need to decide whether to:
> >   a) leave as-is
> >   b) revert permanently
> >   c) revert for 5.15.x but keep the new behaviour in 6.x
> 
> How about:
> 
> d) Follow the C++ trend of banning implicit conversions and make the
> function fail for all input that is as underspecified as a QByteArray.

We can probably do this for QCborValue::fromVariant in Qt 6, since there 
aren't many people using it. QJsonValue::fromVariant might cause the same 
headache.

There are other types that badly convert too. Take, for example, 
QMetaType::ULongLong. You'll agree with me that it's useful to permit 
converting quint64(0), so it shouldn't be a banned conversion. But what 
happens to QUINT64_C(1) << 63 ?

In Qt 5.15, that number is too big for int, so it's stored as a double and no 
precision is lost. When you serialise it, you get "9223372036854775808". In Qt 
6.0, because we added support for 64-bit *signed* integers, that number first 
gets converted to signed, which means it becomes negative. When you serialise 
it, you get "-9223372036854775808". That's the opposite (literally) of what 
you wanted.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Development mailing list