summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
Commit message (Collapse)AuthorAgeFilesLines
* QCborMap: add missing comparator to QCborValueConstRefThiago Macieira35 hours2-1/+14
| | | | | | | | | And ensure all combination of CBOR types are tested. Amends e5ebb9022ab9e00ab01d0bce527755da77083217 Change-Id: I5f663c2f9f4149af84fefffd17c02d352cd41f3f Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* QJsonArray iterators: use new comparison helper macrosTatiana Borisova36 hours2-47/+130
| | | | | | | | | | | | | | | | New comparison macros are used for following classes: - QJsonArray::iterator - QJsonArray::const_iterator Replace public operators operator==(), operator!=(), operator!<(), etc of classes to friend methods comparesEqual(), compareThreeWay(); Use *_helper methods to have an access to protected members of QCborValueConstRef class from friend functions. Task-number: QTBUG-120300 Change-Id: I9b41b619107ce69d8b6dab4938232fab841aab51 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTextStream: discard+comment the possibility of file opening failureGiuseppe D'Angelo37 hours1-1/+4
| | | | | | | | | | | | The QTextStream(FILE*) constructor may fail to open the filehandle through QFile (e.g. if the open mode is incompatible). However QTextStream has no error report mechanism for this and still reports status Ok. This is consistent for instance with the QIODevice* constructor, where even passing a closed device sets the status to Ok. Add a comment and discard the return of open(). Change-Id: I430b96fd26e0ebca15a4d9ee640b09895bdd0b03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonObject: use new comparison helper macrosTatiana Borisova2 days2-18/+32
| | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonObject to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonObject, QJsonValue) to the QJsonObject class, to support comparison between QJsonObject and QJsonValue elements, see test-case valueEquals(). Task-number: QTBUG-120300 Change-Id: Ibab0b4b39966205447e31c41e94e7e1a4e31e553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonValue: use new comparison helper macrosTatiana Borisova6 days2-40/+61
| | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonValue/QJsonValueConstRef/QJsonValueRef classes to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Delete non-exported public operators operator==(), operator!=() for QJsonValueConstRef/QJsonValueRef classes. Add comparison check to auto-test. Task-number: QTBUG-120300 Change-Id: I01434af4ce5a7589733db4a9b14f54ad42e852ed Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonDocument: use new comparison helper macrosTatiana Borisova6 days2-12/+20
| | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonDocument to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120300 Change-Id: I7b61765c34406b7a9fb7dd8b1fc554c87af6a3f3 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonArray: use new comparison helper macrosTatiana Borisova6 days2-18/+35
| | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonArray to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonArray, QJsonValue) to the QJsonArray class, to support comparison between QJsonArray and QJsonValue elements, see test-case fromToVariantConversions() Task-number: QTBUG-120300 Change-Id: I8440ca0761bede8551ff792bfa7f22e47b56fa79 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Xml: use new comparison helper macrosTatiana Borisova8 days2-39/+82
| | | | | | | | | | | | | | | | | | | | | | New comparison macros are used for following classes: -QXmlStreamAttribute -QXmlStreamNamespaceDeclaration -QXmlStreamNotationDeclaration -QXmlStreamEntityDeclaration Replace public operators operator==(), operator!=() of classes to friend methods comparesEqual(); Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Add checkStreamNotationDeclarations()/checkStreamEntityDeclarations() test-cases to test change. Task-number: QTBUG-120300 Change-Id: I0b5642b2e23cc21ede7bc4888f0a9bddd6c08d07 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborMap: use new comparison helper macrosTatiana Borisova8 days2-19/+100
| | | | | | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=(), operator<() of QCborMap to friend methods comparesEqual() / compareThreeWay(). Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Delete #if 0 && __has_include(<compare>) blocks, since they are not required anymore. Add friend methods comparesEqual(QCborMap, QCborValue) and compareThreeWay(QCborMap, QCborValue) to the QCborMap class, to support comparison between QCborMap and QCborValue elements, see test-case mapSelfAssign() -> QT_TEST_EQUALITY_OPS(it.key(), QCborMap({{0, v}}), true); Task-number: QTBUG-120300 Change-Id: I9e33df255d16484efd3124cf0632db859408fb5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QCborArray: use new comparison helper macrosTatiana Borisova9 days2-18/+78
| | | | | | | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=(), operator<() of QCborArray to friend methods comparesEqual() / compareThreeWay(). Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Delete #if 0 && __has_include(<compare>) blocks, since they are not required anymore. Add friend methods comparesEqual(QCborArray, QCborValueConstRef) and compareThreeWay(QCborArray, QCborValueConstRef) to QCborArray to support comparison between QCborArray and QCborValueRef/QCborValueConstRef, see test-case mapMutation(). Add QT_TEST_EQUALITY_OPS/QT_TEST_ALL_COMPARISON_OPS tests for QCborArray test-cases. Task-number: QTBUG-120300 Change-Id: Ifad1a04c61363618e8bba73cf7c87757552d722a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborValueConstRef/QCborValueRef: use new comparison helper macrosTatiana Borisova9 days2-27/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | Replace public operators operator==() and operator!=() of QCborValueConstRef and QCborValueRef classes to friend methods comparesEqual(). Replace public operator<() of QCborValueConstRef and QCborValueRef classes to friend methods compareThreeWay() respectively. Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Delete #if 0 && __has_include(<compare>) blocks, since they are not required anymore. Add comparison() test-case for QCborValueConstRef/QCborValueRef testing. Add QCborValue::operator==()/QCborValue::operator!=()/ QCborValue::operator<() and QCborValueRef::operator==()/ QCborValueRef::operator!=()/QCborValueRef::operator<() operators to the removed_api file. Task-number: QTBUG-120300 Change-Id: I2e8e4e32b7b5b49da321364cc12986e9c64b5f37 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborValue: use new comparison helper macrosTatiana Borisova10 days1-1/+1
| | | | | | | | | Add qcborvalue.h header to removed_api.cpp file Ammends from 15da9c75d0a05b7451a35b5b6a3c940f9cb85143 Task-number: QTBUG-120300 Change-Id: Ic33bf80298730f2c3fd408ffb45f0e1b32f531fc Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Bootstrap: remove the UTF-16 and UTF-32 codecsThiago Macieira2024-03-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Unlike most of everything else in the Bootstrap lib, this is code that couldn't be eliminated by the linker because they were referenced in one static array. Maybe an exceptionally smart whole-program analysis could do it, but GCC and Clang LTO modes don't do that now. I removed the code that performed detection from HTML and from data too. I could have left the detection of UTF-8 and "other" but this code wasn't necessary. In particular, QTextStream couldn't benefit from it because it already defaults to UTF-8, so the detection code would never determine anything different from the input. Drive-by removed QStringConverter::availableCodecs() too because it was in the middle of functions #ifdef'ed out to. This reduced the size of release-mode moc text data bss dec hex filename 1079858 5440 640 1085938 1091f2 original/moc 1074386 5200 640 1080226 107ba2 updated/moc -5472 -240 0 -5712 difference Change-Id: I01ec3c774d9943adb903fffd17b7f114c42874ac Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Bootstrap: remove qnumeric.cpp by using qnumeric_p.hThiago Macieira2024-03-132-4/+5
| | | | | | | | | That is, use the inline functions that refer to <numeric_limits> and <cmath> directly, instead of the out-of-line wrappers. Someone should verify if the hacks for QNX's <math.h> are still required. Change-Id: I01ec3c774d9943adb903fffd17b7ee560b4b71b9 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QCborValue: use new comparison helper macrosTatiana Borisova2024-03-132-21/+68
| | | | | | | | | | | | | | | | | | | Replace public operators operator==() and operator!=() of QCborValue to friend method comparesEqual(). Replace public operator<() of QCborValue to friend method compareThreeWay(). Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Delete #if 0 && __has_include(<compare>) blocks, since they are not required anymore. Task-number: QTBUG-120300 Change-Id: I884ff6ce2a71618b0e3eaa907f0852f93c2a073c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Bootstrap: remove QVariantThiago Macieira2024-03-135-1/+18
| | | | | | | | | I added QT_NO_VARIANT to qconfig-bootstrapped.h to be clearer on what the #ifs are, but there's no testing of that feature outside of QT_BOOTSTRAPPED. Change-Id: I01ec3c774d9943adb903fffd17b7e8ac4340fb89 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Bootstrap: remove QDataStreamThiago Macieira2024-03-131-1/+1
| | | | | | | | | | | It was only used by the cmake_automoc_parser so it would write a 64-bit in big-endian format. So bypass QDataStream and write it native endianness. Change-Id: I01ec3c774d9943adb903fffd17b79c78e56db4cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QDataStream: make the public-ish private members smaller in Qt 7Thiago Macieira2024-03-121-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pahole says: class QScopedPointer<QDataStreamPrivate> d; /* 0 8 */ class QIODevice * dev; /* 8 8 */ bool owndev; /* 16 1 */ bool noswap; /* 17 1 */ quint8 fpPrecision; /* 18 1 */ quint8 q_status; /* 19 1 */ enum ByteOrder byteorder; /* 20 4 */ int ver; /* 24 4 */ quint16 transactionDepth; /* 28 2 */ /* size: 32, cachelines: 1, members: 10 */ Which is unnecessary overhead. The previous commit took care of byteorder for Qt 7; this one reduces the size a bit more, to 16 bytes on 32-bit systems and 24 on 64-bit ones. After this, pahole says for the bootstrap library: class QScopedPointer<QDataStreamPrivate> d; /* 0 8 */ class QIODevice * dev; /* 8 8 */ bool owndev; /* 16 1 */ bool noswap; /* 17 1 */ quint8 fpPrecision; /* 18 1 */ quint8 q_status; /* 19 1 */ enum Version ver; /* 20 1 */ /* XXX 1 byte hole, try to pack */ quint16 transactionDepth; /* 22 2 */ /* size: 24, cachelines: 1, members: 9 */ Further packing isn't possible, because of the alignment at 64-bit for this class. Change-Id: I50e2158aeade4256ad1dfffd17b29b80237a8c5b Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QDataStream: don't store the byteorder member in Qt 7Thiago Macieira2024-03-122-3/+12
| | | | | | | | | | | It's redundant with the noswap member: we swap if the stream byte order is the opposite of the CPU's and don't swap if it is the same. That the default is to swap is another reason why people should stop using QDataStream (though CBOR also stores numbers in big-endian). Change-Id: I50e2158aeade4256ad1dfffd17b29adc2b698ead Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDataStream: use NSDMIThiago Macieira2024-03-122-25/+6
| | | | | | | | Just a little clean-up to avoid repetition. Change-Id: I50e2158aeade4256ad1dfffd17b29a5b36c71ddc Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: Move trasactionDepth to the main classThiago Macieira2024-03-123-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The q_status member has too much space dedicated to it: 32 bits. So we can shrink it to a mere 8 bits and move it up to the 1-byte padding hole and repurpose the space it used to use. This only works because the q_status member was not accessed by any inline function before Qt 6.8 (see commit fc23fa459c5924bf1cc4564c7bce1fd59d7c972b). After this, pahole says: class QScopedPointer<QDataStreamPrivate> d; /* 0 8 */ class QIODevice * dev; /* 8 8 */ bool owndev; /* 16 1 */ bool noswap; /* 17 1 */ quint8 fpPrecision; /* 18 1 */ quint8 q_status; /* 19 1 */ enum ByteOrder byteorder; /* 20 4 */ int ver; /* 24 4 */ quint16 transactionDepth; /* 28 2 */ /* size: 32, cachelines: 1, members: 10 */ That leaves 16 bits of tail padding unused, so reduces the maximum number of nested transactions to 65536. That is to support a Qt 7 layout in an upcoming commit. Change-Id: I50e2158aeade4256ad1dfffd17b29d75fd13f472 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QDataStream: inline floatingPointPrecision()Thiago Macieira2024-03-123-12/+11
| | | | | | | | | | | | | | | | | | | | | | There is a 2-byte padding in all architectures between the noswap member and byteorder, because the latter requires a 32-bit alignment. So we can use this space to store this little-used field and avoid one more reason for QDataStreamPrivate. Now: class QScopedPointer<QDataStreamPrivate> d; /* 0 8 */ class QIODevice * dev; /* 8 8 */ bool owndev; /* 16 1 */ bool noswap; /* 17 1 */ quint8 fpPrecision; /* 18 1 */ /* XXX 1 byte hole, try to pack */ enum ByteOrder byteorder; /* 20 4 */ int ver; /* 24 4 */ enum Status q_status; /* 28 4 */ /* size: 32, cachelines: 1, members: 9 */ Change-Id: I50e2158aeade4256ad1dfffd17b29c2c5db02c12 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QCborStreamReader: rename toStringish() -> readAllStringish()Ivan Solovev2024-03-122-15/+15
| | | | | | | | | | | | Amends 8af346c1f66f813c3c8fe4d8b892ecfbe96eacfb and 1d9137e13f9eb3f183c967e9e911c5b260f93dc0. Found in 6.7 API review Task-number: QTBUG-123115 Pick-to: 6.7 6.7.0 Change-Id: I98d79274f26f3439302a59181401b6e244fe5202 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborStreamReader: rename appendToType() -> readAndAppendToType()Ivan Solovev2024-03-122-18/+21
| | | | | | | | | | | | Amends ff034ebbfa7c1cc47cdcc15bc854972cd960db1a. Found in 6.7 API review Task-number: QTBUG-123115 Pick-to: 6.7 6.7.0 Change-Id: Id5e95aacffcb633701d4d635d2bf8af70984903e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correct license for tools filesLucie Gérard2024-03-051-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tools file should be LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: Icd5d5be2e04819617e68ff142924de1773bebbad Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* QCborStreamReader: don't assume that clear() results in isNull()Marc Mutz2024-02-291-3/+3
| | | | | | | | | | | | | | | | | That QString and QByteArray::clear() shed all capacity() is a historical artifact we will fix at some point. Don't add more code that assumes a clear()ed string isNull(). Amends 8af346c1f66f813c3c8fe4d8b892ecfbe96eacfb. Amends 1d9137e13f9eb3f183c967e9e911c5b260f93dc0. Task-number: QTBUG-31283 Task-number: QTBUG-60745 Pick-to: 6.7 Change-Id: Ib0d929325088d3e8e119fee3eafa964a783dc8e9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* QCborStreamReader: rename toType(Type&) -> appendToType(Type&)Ivan Solovev2024-02-292-21/+18
| | | | | | | | | | | | | | | Rename the toType() overloads taking an out-parameter to appendToType(), because that gives a better understanding of the usecase. Found in 6.7 API review Amends 8af346c1f66f813c3c8fe4d8b892ecfbe96eacfb and 1d9137e13f9eb3f183c967e9e911c5b260f93dc0. Pick-to: 6.7 Change-Id: Ic1a462e9507123a59e6086bfb48b8b61ab79abb8 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: code tidiesGiuseppe D'Angelo2024-02-281-1/+1
| | | | | | | | | | | | | | | As spotted in the code review, remove_cv here is useless. Since T is passed by value, template type deduction will strip cv-ref for us. (Also: in general we don't support users specifying template type parameters except where authorized, but here they can't, as this is an operator.) Amends 3823e310e39426043dc7f0529a6fba33fe4d49f0 Change-Id: I5b5db38a4dcf4f1179d748cf0bb1b62a9896f5a6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Containers: add max_size()Giuseppe D'Angelo2024-02-272-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One more method for STL compatibility. This one is particularly subtle as it's required by the `reservable-container` concept: https://eel.is/c++draft/ranges#range.utility.conv.general-3 Without this concept, ranges::to won't reserve() before copying the elements (out of a sized range which isn't a common_range). Implementation notes: there were already a couple of constants denoting the maximum QByteArray and QString size. Centralize that implementation in QTypedArrayData, so that QList can use it too. The maximum allocation size (private constant) needs a even more central place so that even QVLA can use it. Lacking anything better, I've put it in qcontainerfwd.h. Since our containers aren't allocator-aware, I can make max_size() a static member, and replace the existing constants throughout the rest of qtbase. (I can't kill them yet as they're used by other submodules.) [ChangeLog][QtCore][QList] Added max_size(). [ChangeLog][QtCore][QString] Added max_size(). [ChangeLog][QtCore][QByteArray] Added max_size(). [ChangeLog][QtCore][QVarLengthArray] Added max_size(). Change-Id: I176142e31b998f4f787c96333894b8f6653eb70d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: Turn QDataStreamSizes enum into static contexpr quint32Øystein Heskestad2024-02-232-7/+11
| | | | | | | | | | The special sizes NullCode and ExtendedSize does not need to be part of an enum. Turning them into constants removes the need for some casts. Task-number: QTBUG-119952 Pick-to: 6.7 Change-Id: Ie7835c52f4642ab907b91f0eceac2ea7650e81da Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QDataStream: reimplement and constrain operator<<(bool)Giuseppe D'Angelo2024-02-202-11/+14
| | | | | | | | | | | | | | | | | Instead of offering it as a plain overload, make it a template and constrain the argument to be precisely bool. This removes the danger of accidentally streaming things that are convertible to bool, such as pointers, by, indeed, converting them to bool. This allows us to remove the deleted overloads for pointers to objects and pointers to members. The existing operator<<(bool) is exported, hence I moved it into removed_api.cpp. Since the implementation required private QDataStream APIs, I've just "inlined" the implementation that simply routed through the operator<<(qint8) overload. Change-Id: I3c0a9811bf5c9e734e28514b37bcaaddb09ada25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: also disable streaming of member pointersGiuseppe D'Angelo2024-02-161-0/+2
| | | | | | | | | 2fd4a86dc5547d6ff3f512bd33ccf6e10d159ff4 disabled the streaming of pointer with QDataStream, as they would otherwise accidentally select the `bool` overload. Do the same for member pointers. Change-Id: I4910953a2856957518b4e51bdc4a0c26d75addab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: inline status()Marc Mutz2024-02-122-5/+10
| | | | | | | | | | | | | The implementation is trivial, and unchanged since the beginning of the public project history, so I'd venture that it's safe to commit to it not changing until Qt 7 at this point. The reason to make it inline is that a good stream operator implementation should be checking the stream state quite often, so we shouldn't make that an expensive DLL entry point. Change-Id: Iba8cbfbaf02326c86ab95be17b603cd2e785f78c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* serialization: cborparser - silence gcc warningTim Blechmann2024-02-081-0/+1
| | | | | | Change-Id: Ic28f85e7f6efbd65c79d67ce2fb3a367f36412fb Pick-to: 6.7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate QDataStream::readBytes(char *&, uint &) instead of removing itIvan Solovev2024-02-072-1/+26
| | | | | | | | | | | | | | | | | | | | | | We cannot remove the overload using QT_REMOVED_SINCE, because a qint64 lvalue in the new overload will not bind to an uint& parameter, so the old code would not compile. Deprecate the old overload, and add a unit-test that makes sure that it still behaves correctly. This commit also introduces the new deprecation macros that are required to do the deprecation in Qt 6.11. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: I02893bfbe040df736f8e746384e0261a0f0041d3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QDataStream::operator<<(const char *) to handle 64-bit lengthIvan Solovev2024-02-071-7/+3
| | | | | | | | | | | | | | | The operator was not converted to using a new streaming version, so it supported only 32-bit length. Fix it and add a manual test for serialization/deserialization of large c-style strings. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Pick-to: 6.7 Change-Id: I83704edec021d400b992de810feba5da52d5ffe1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDataStream::readBytes(): only chunk when data is not all availableIvan Solovev2024-02-071-1/+1
| | | | | | | | | | | | | | If the underlying QDataStream's device already contains all data that we want to read, we can optimize the allocation algorithm, and try to allocate all needed memory at once. Use bytesAvailable() to determine if the underlying device can provide all requested data, and adjust the initial block size based on the result. If not all data is available, fall back to the geometric growth algorithm. Change-Id: I6384d2caa16c238c2dbb77b2ad761cbd8a44df6c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream::readBytes(): make the growth of the buffer geometricIvan Solovev2024-02-071-2/+3
| | | | | | | | | | | | | The algorithm tries to allocate the memory using 1 Mb blocks. When the input data is large, this results in a lot of reallocations, which is slow and inefficient. This patch modifies the algorithm in such way that the allocation size increases at each step, resulting in geometric growth of the buffer. Pick-to: 6.7 6.6 6.5 Change-Id: I071df68d51ba1dbd8b2eb5f94eb078a33223505f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: use SizeLimitExceeded status in write operationsIvan Solovev2024-02-072-12/+18
| | | | | | | | | | | | | | | | | | | | | | Set this status when the stream tries to write more data than the current serialization format supports. Update the methods that write containers to return early if they fail to write the container size, and do not try to serialize the elements. Convert the manual tst_manualqdatastream test into a data-driven test, allowing us to specify various stream versions. Adjust the test code to check that the SizeLimitExceeded status is set when the stream version is <= Qt_6_6. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: If4c62ea53ac9bccd423f00f0f03afd6ba6bdc4f5 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: use qint64 to represent size while reading and writingIvan Solovev2024-02-072-17/+15
| | | | | | | | | | | | Do that to avoid narrowing at the call site on 32-bit platforms. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: I31142399385521d973b2ed3789745569e44d5d63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* corelib: serialization - fix macos unity buildsTim Blechmann2024-02-061-42/+50
| | | | | | | | | CarbonCore defines `DEBUG`, which can nameclash with the `DEBUG` define in the json parser when using unity builds Change-Id: Ic9f666a1da98aaebe30836abf877228f2f83004c Pick-to: 6.7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement QCborContainerPrivate::compact()Ivan Solovev2024-02-052-14/+43
| | | | | | | | | | | | | | ... and use it in QCborContainerPrivate::replaceAt_complex() to avoid unconstrained memory growth in certain scenarios. Remove the `reserved` parameter, because it was referring to the elements array, not to the byte data, so it cannot really be used in the implementation. Fixes: QTBUG-109073 Pick-to: 6.7 Change-Id: I2e8fe7e4a4bf7a0ce06c87ca657f2bc01bae0341 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* StreamStateSaver: disable copy/moveMarc Mutz2024-02-021-0/+1
| | | | | | | | | | | | The class has a user-defined destructor, so it mustn't be copied or moved (which here is the same as copying). Amends 3c93286f08a80b6e1821d7d63d361742b25c6578. Pick-to: 6.7 6.6 6.5 Change-Id: I1b23588309654f34aedc0269e1d1c9511ddda2bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QJsonArray: symmetrize QDataStream op>>/<<Marc Mutz2024-01-291-3/+1
| | | | | | | | | | | | | In operator<<(), stream the QJsonDocument directly, instead of toJson(Compact). This is how QJsonDocument operator<<() also does things, but that knowledge should be need-to-know, and QJsonArray doesn't, seeing as operator>>() just streams a QJsonDocument, and then calls toArray(). Pick-to: 6.7 6.6 6.5 Change-Id: Ia378bf0fb04ce33e3af24a2ce67778e89c41e31a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QDataStream: add a new SizeLimitExceeded status codeIvan Solovev2024-01-262-5/+11
| | | | | | | | | | | | | | | | | | This status is supposed to be used when the stream tries to read or write more data than it is supported by the current platform. For example, reading more than 2 GiB of data on a 32-bit platform will result into this status, but it will work fine on a 64-bit platform. This patch uses the new status in read operations. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: I675b1ee25fafba174ce8f94c3470dbb7893d6d9e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborStreamReader::lastError() - fix REMOVED_SINCE versionIvan Solovev2024-01-121-1/+1
| | | | | | | | | | | | | | The definition in removed_api.cpp is added within the proper #ifdef block, only the version in the header was wrong. Amends 8e8815b688684f5b267db1c2d8ac99c8f7f7637a Found in 6.7 API Review Pick-to: 6.7 Change-Id: I0a94bfaae8b3db700c794aa83d9637ec85edffb1 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: add missing #include <iterator>Thiago Macieira2024-01-101-0/+2
| | | | | | | | | | | | For std::distance() and std::next(). Amends 003c29511de5979fba526acd62f2a4c7c356b982. Pick-to: 6.2 6.5 6.6 6.7 Task-number: QTBUG-114583 Change-Id: I6e2677aad2ab45759db2fffd17a7318d396cbc4d Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QDataStream & QResource: document their lack of security-hardeningThiago Macieira2023-12-211-0/+21
| | | | | | | | | Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-120012 Task-number: QTBUG-119178 Change-Id: I6e2677aad2ab45759db2fffd17a06af730e320d6 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCbor/QJson: s/QPair/std::pair/Marc Mutz2023-12-133-10/+10
| | | | | | | | | Also port qMakePair() to just braced initialization and CTAD. Pick-to: 6.7 Task-number: QTBUG-115841 Change-Id: I9eafb20ebc63bd33eb52661f4f14ad2db9fc0f00 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Bump version to 6.8.0Jani Heikkinen2023-12-112-2/+4
| | | | | Change-Id: I407e6fd7a766450bb6fe00da7f6ebbd49496e5cd Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>