summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
Commit message (Collapse)AuthorAgeFilesLines
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-212-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* JSON: Further improve the duplicate handling in the parserUlf Hermann2022-01-211-3/+15
| | | | | | | | Avoid some unnecessary comparisons and add more tests. Task-number: QTBUG-99799 Change-Id: I3aee9f0b62461d38dadbe8e969444e1cd1f94e68 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QtCore: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-01-206-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by providing a hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. Don't document it, otherwise we'd be unable to pick it to 6.2. Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build: before: **** Template sets that took longest to instantiate: [...] 27766 ms: qSwap<$> (9073 times, avg 3 ms) [...] 2806 ms: std::swap<$> (1229 times, avg 2 ms) (30572ms) after: **** Template sets that took longest to instantiate: [...] 5047 ms: qSwap<$> (641 times, avg 7 ms) [...] 3371 ms: std::swap<$> (1376 times, avg 2 ms) [qt_ptr_swap<$> does not appear in the top 400, so < 905ms] (< 9323ms) As a drive-by, remove superfluous inline keywords and template ornaments. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* JSON: When clearing duplicate object entries, also clear containersUlf Hermann2022-01-181-10/+44
| | | | | | | | | | | | | | | | | Previously, if you had multiple entries with the same name in an object, and some of them were again objects or arrays, parsing the JSON document would leak memory. Also, we use std::stable_sort instead of std::sort now, so that we don't accidentally randomize the order of elements with equal keys. [ChangeLog][QtCore][JSON] A memory leak in the JSON parser when reading objects with duplicate keys was fixed. Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-99799 Change-Id: Ic2065f2e490c2d3506a356745542148ad9c24262 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Use \inmodule for all classes and headersTopi Reinio2022-01-171-1/+1
| | | | | | | | | | | | | | | QDoc made some assumptions about the module a class/header belongs to, based on the source file path. This feature is rather error-prone and unnecessarily complex and will be removed from QDoc. Define modules explicitly to avoid documentation warnings when this removal happens. Pick-to: 6.2 6.3 Change-Id: I7947d197db5ac36c12e816caa19bb2f74eda8849 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Replace QString::utf16 with QString::data where appropriateØystein Heskestad2022-01-171-1/+1
| | | | | | | | | | | QString::utf16() needlessly detaches fromRawData() to ensure a terminating NUL. Use data() where we don't require said NUL, taking care not call the mutable data() overload, which would detach, too. Task-number: QTBUG-98763 Change-Id: Ibd5e56798c0c666893c12c91ff0881842b8430c7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTextStream: code tidiesGiuseppe D'Angelo2022-01-162-10/+13
| | | | | | | | | | | | Port the internals to qsizetype, and use QStringView instead of QString as a function parameter. The padding() function is changed to take a qsizetype to avoid warnings, but the maximum padding that can be specified is still limited by the range of an int (this is guarded via an assert). Change-Id: I9dd98e5a534990a1758b080900a12dc793528d19 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QJsonObject: use the UTF-8 string comparator in sortingThiago Macieira2022-01-122-4/+2
| | | | | | | | | | No change, the two functions are identical for case-sensitive comparison. But this allows us to remove the comment that explained why we were abusing the Latin1 comparator. Change-Id: I0e5f6bec596a4a78bd3bfffd16c98bbcac6c9dc9 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDataStream: remove pointless guard around std::pair operatorsMarc Mutz2021-11-041-2/+0
| | | | | | | | | | | The code is already in 'ifndef QT_NO_DATASTREAM'. Well, the condition is a bit more complicated, which makes this nested guard even more wrong. Amends 55150f0f0bac0a6343da60d8128fc4216b57db2b. Change-Id: I1c8f35ebc0355185244c8bf098d000b7c5c543d5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix docs for comparison/debug/data stream operators of Qt containersSona Kurazyan2021-10-181-0/+48
| | | | | | | | | | | | | | Because of the constraints on comparison, debug and data stream operators, the return types for them look weird in docs. Conditionally use the actual return types, in case if Q_CLANG_QDOC is defined. Also add the docs of debug stream operators for types for which they were misssing. Task-number: QTBUG-97247 Pick-to: 6.2 Change-Id: I57f2c52bd3af805c7eeebb602c47de1e95ee09bd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* corelib: Fix typos in documentationJonas Kvinge2021-10-125-9/+9
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* corelib: Fix typos in source code commentsJonas Kvinge2021-10-122-2/+2
| | | | | | Pick-to: 6.2 Change-Id: Ic78afb67143112468c6f84677ac88f27a74b53aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Convert all QT_VERSION checks to compare against QT_VERSION_CHECK()Edward Welbourne2021-09-231-2/+2
| | | | | | | The result is generally more readable. Change-Id: I507f67954ecd38516de1b7a6f8244c233ee45ddf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Centralize RFC documentation-links in rfc.qdocLuca Di Sera2021-09-168-21/+20
| | | | | | | | | | | | | | | | | | | | In the effort of repairing broken links as per QTBUG-96127, a series of RFC links referring to `tools.ietf.org/html/*` were modified to point to the new address that the site redirected to. To simplify executing a similar task and to diminish the duplication of manually inserted urls, the already existing `rfc.qdoc` file, containing `\externalpage` commands directing to RFC locations, was enhanced with links to all RFCs that were mentioned in the current documentation, so as to aggregate this common category of links. All links pointing to a `ietf` domain inside QDoc documentation blocks were then changed to use the newly provided external-references. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDataStream: Add reminders to remove operators for qfloat16Ievgenii Meshcheriakov2021-09-141-0/+2
| | | | | | | | | | | | | Having I/O operators defined for incomplete types causes hard to diagnose problems when types with template conversion operators are used as arguments to signals or slots. Removing qfloat16 operators is not possible before Qt 7 because of backward compatibility. Task-number: QTBUG-93499 Change-Id: Ifa296bb58c45a06abf79dbe5666a666adaa8eab9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Adjust src/corelib/serialization/qdatastream.[h/cpp] for 6.3.0Shawn Rutledge2021-09-142-2/+4
| | | | | Change-Id: I9809d6122c6d3c5ad5753d52679f4ac67a17e3d4 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix compilation for recursive Qt containersSona Kurazyan2021-09-071-12/+19
| | | | | | | | | | | | | | | | | | | | The operator checks cause compilation errors when trying to check for their existence for recursive containers. This happens because of trying to check for the operators on the template parameter type(s), that inherit from the container itself, which leads to compilation errors. Introduced alternative versions of the operator checks (with _container suffix), that first check if the container is recursive, i.e. any of its template parameter types inherits from the given container, and skips the operator check, if that's the case. The fix is done for all Qt container types that had the problem, except for QVarLengthArray and QContiguousCache, which don't compile with recursive parameter types for unrelated reasons. Fixes: QTBUG-91707 Pick-to: 6.2 6.1 Change-Id: Ia1e7240b4ce240c1c44f00ca680717d182df7550 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* JSON parsing: fix incorrect sign-extension for decoding bad escapesThiago Macieira2021-09-061-3/+3
| | | | | | | | | | | | | | The parser was lenient in accepting backslashes followed by invalid characters, but accidentally sign-extended everything above 0x7f causing broken outputs that weren't valid UTF-16 either. For example, the sequence "\\\xff" (backslash followed by 0xff) produced sequence "\ud7bf\udfff" (U+D7BF is not a surogate pair). Change-Id: Ie72b0dd0fbe84d2caae0fffd16a113c703a7696f Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* corelib: Use char16_t and char32_t types for charactersIevgenii Meshcheriakov2021-09-062-8/+8
| | | | | | | | | Use standard char16_t and char32_t types instead of ushort and uint. Remove members of QUtf8BaseTraits that use those integer types. Change-Id: I77b1a9106244835c813336a50417f6bbdfada288 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCborValue: add asserts to encoding methodIvan Solovev2021-08-191-0/+2
| | | | | | | | | | | | | | This patch is inspired by CodeChecker, that is complaining about possible nullptr dereferencing. Currently it is a false-positive, because the codepath suggested by CodeChecker is impossible with current implementation. But having asserts can save some time in case of possible refactoring. Task-number: QTBUG-95727 Pick-to: 6.2 Change-Id: I242a23e8aaa249cce16b867c0884dfc3849977f5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QTextStream: Always use direct connection inside QDeviceClosedNotifierIevgenii Meshcheriakov2021-07-271-2/+7
| | | | | | | | | | | | | | | | | | | | Force direct connection when connecting aboutToClose() signal of device to flushStream() slot of QDeviceClosedNotifier. This allows use of a QTextStream from multiple threads when synchronization is handled by the application. Queued connections from aboutToClose() don't make much sense because the device is closed immediately after emitting the signal. If a QTextStream object is used by threads different from the one where it was created, queued connection may result in attempting to flush the data after the associated device is already closed, and accessing the QTextStream's buffers from multiple threads. Fixes: QTBUG-12055 Change-Id: If601d0f04f08b248b21ed1630b7dfd3546aee068 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QJsonValue: add rvalue overloads for QJsonArray and QJsonObject ctorsMarc Mutz2021-07-065-0/+45
| | | | | | | | | | | | | | | | | | These can be noexcept. Requires to add rvalue overloads for QCborMap::fromJsonObject() and QCborArray::fromJsonArray(), too. [ChangeLog][QtCore][QJsonValue] Added constructors taking rvalue QJsonArray and rvalue QJsonObject. [ChangeLog][QtCore][QCborMap] Added rvalue overload of fromJsonObject(). [ChangeLog][QtCore][QCborArray] Added rvalue overload of fromJsonArray(). Change-Id: I523c9a41166ea932fba4dd204072bd39d2192d2e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTextStream: fix a dead writeMarc Mutz2021-06-171-2/+1
| | | | | | | Found by Clazy. Change-Id: Iabe4fb23f63ea8df2142dc66cd16b04526b628c2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Consolidate debug string generationAlex Trotsenko2021-05-311-45/+4
| | | | | | | | | | | | | | Several QIODevice subclasses use the qt_prettyDebug() function to get a printable representation of the buffer data for debug output. Rather than having this feature statically implemented in each respective file, this patch introduces a generic function in the QtDebugUtils namespace. Accordingly, some inaccuracies in the use-cases have been corrected. Change-Id: I1a8465cab08c8acf5fdcdba5085182511b1cbb7b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qcborstreamreader.cpp: Use QT_TRY/QT_CATCHNodir Temirkhodjaev2021-05-231-4/+4
| | | | | | | | | | | | | | | | | | To avoid build error with no exceptions: qtbase/src/corelib/serialization/qcborstreamreader.cpp:1586:9: error: cannot use 'try' with exceptions disabled try { ^ qtbase/src/corelib/serialization/qcborstreamreader.cpp:1629:9: error: cannot use 'try' with exceptions disabled try { ^ 2 errors generated. Used compiler: https://github.com/mstorsjo/llvm-mingw It's not a supported configuration, but the change is simple. Change-Id: I263ce23b458f114b2330e832c5f4fd2a99cbb973 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correct prefix reported for end element in QXmlStreamReaderVincent Baijot2021-04-202-0/+4
| | | | | | | | | | | | | | | | | | | Before this change, QXmlStreamReader prefix value was always an empty string for EndElement when the documentation state : "Returns the prefix of a StartElement or EndElement." The error was a missing update of the prefix value when parsing EndElement. I updated the tests data which were also wrong because no prefix were reported even for </a:foo>. No new test is necessary, I think, the test data already cover the cases of EndElement with a prefix and without one (unchanged here). Fixes: QTBUG-86847 Pick-to: 5.15 6.0 6.1 Change-Id: I0ad38b9741d760f1ce688a36f969ec14e20a928c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't parse XML symbols longer than 4096 charactersAllan Sandfeld Jensen2021-04-161-0/+5
| | | | | | | | | It is slow and will use too much memory. Pick-to: 6.1 6.1.0 6.0 5.15 Fixes: QTBUG-91889 Change-Id: I45c5e6038357c87bbb85b1ace17ef39a2a814ea0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonValueRef: add missing operator[]Fabian Kosmale2021-02-261-0/+4
| | | | | Change-Id: Iae165cd7bb2a7ea02d819fa25e0618d81f9a54f4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use Core library for qmake instead of the Bootstrap libraryAlexey Edelev2021-02-251-2/+0
| | | | | | | | | | | | | | | | | | | Move the qmake-specific logic of the QLibraryInfo class to qmake internals. 'qconfig.cpp.in' now stores information about the library info entries to keep them consistent between qmake and the Core library. qmake requires specific features enabled in the Core library, so building qmake will be skipped if the features are not enabled. All flags directly related to the qmake have been removed from Core lib. Remove all bootstrap related sections from qmake CMakeLists.txt Task-number: QTBUG-89369 Change-Id: I26de157d3bfd4a5526699296e9d46e1c180b89ae Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QJsonObject: Fix operator<=()Ulf Hermann2021-02-181-1/+1
| | | | | | | | | | We had a copy-paste error there. Pick-to: 6.0 6.1 Change-Id: Ib1448197ac4f4641c6559f133f41dcf326f210f1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bump the version of QDataStreamFriedemann Kleint2021-02-182-2/+4
| | | | | | | Amends f731802ba82ad260e155783e0427fb3f6ebd99fe. Change-Id: I1ba758ef4c9d80fbc11ecc78e0480f57c95007e2 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QJsonObject::take: add missing detach() callThiago Macieira2021-01-271-0/+1
| | | | | | | | | | We were modifying shared objects. Pick-to: 6.0 5.15 Fixes: QTBUG-89625 Change-Id: Id6bc735b79cf4beb9454fffd165c56476a5dec04 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Bump versionPaul Wicking2021-01-111-2/+3
| | | | | | | | | CMake edition. Also update default compiled version. Task-number: QTQAINFRA-4126 Change-Id: Ia6f535f553e73bd6b00e2e20752f4961af21ede5 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-65/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* XmlStringRef: remove operator<=>Giuseppe D'Angelo2021-01-041-6/+0
| | | | | | | | | | It's defined in terms of operator<=> on QStringView, which does not exist, causing a compile error. Change-Id: I64fc60da4e52c7e53be7849d9b42952be139a816 Fixes: QTBUG-89729 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Bump versionPaul Wicking2020-12-151-0/+1
| | | | | Change-Id: I33ea33c0ecfe42cd25cb9f3a37b7aad72717edd2 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QCborStreamReader: move helper function to the only place it's usedThiago Macieira2020-12-091-25/+17
| | | | | | | | Simplifies the code a little bit Pick-to: 5.15 6.0 Change-Id: I7b9b97ae9b32412abdc6fffd164545632be4590a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborStreamReader::next: don't allocate too much memory in a QBAThiago Macieira2020-12-071-13/+12
| | | | | | | | | | | | | | | | | | | | Because CBOR strings are encoded in UTF-8, it's possible that the string that won't fit a QString in UTF-16 would still fit QByteArray in UTF-8 (e.g., anything US-ASCII and most Latin text). The previous solution was an improvement because we used to read into a QByteArray then convert the QByteArray to QString, thus using 3x the amount of memory (1x in QByteArray, 2x in QString). The previous commit skipped the middle allocation and made the regular readString() function do the decoding either directly on source memory or by reading in small chunks (16 kB). Future improvement for Qt 6.1: add readStringChunk(char16_t *, qsizetype) so we can do the validation / skipping at O(1) memory. Pick-to: 5.15 6.0 Change-Id: I7b9b97ae9b32412abdc6fffd1645458c655cc566 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborStreamReader: move the UTF-8 decoding into readStringChunkThiago Macieira2020-12-071-37/+109
| | | | | | | | | | | This allows us to decode long UTF-8 strings in chunks, instead of allocating a big block of the size of the UTF-8 source and then another for the full UTF-16 content. Pick-to: 5.15 6.0 Task-number: QTBUG-88253 Change-Id: I7b9b97ae9b32412abdc6fffd16452a47b1036ef3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborStreamReader: remove the lambdas from decodeStringFromCbor()Thiago Macieira2020-12-061-43/+32
| | | | | | | | | One was only called once. For the other, one of the calls wasn't necessary. Pick-to: 5.15 6.0 Change-Id: I7b9b97ae9b32412abdc6fffd16454eec59d72b8a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborValue: avoid allocating result if data is insufficientThiago Macieira2020-12-063-49/+71
| | | | | | | | | | | Similar to the previous commit which applied to QCborStreamReader, don't allocate too much data before checking that the stream actually has that much. Pick-to: 5.15 6.0 Fixes: QTBUG-88256 Change-Id: I7b9b97ae9b32412abdc6fffd16454b7568a063ba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborStreamReader: avoid allocating result if data is insufficientThiago Macieira2020-12-061-21/+57
| | | | | | | | | | | | | | | | | | | | | | | By calling the internal readStringChunk() function with a QByteArray pointer, QCborStreamReader::readByteArray() can now avoid allocating the resulting buffer until the internals have confirmed that there is sufficient data in the incoming buffer. As a result, we first detect the EOF condition before we conclude the payload would have been too big for QByteArray (validation()) test. Meanwhile, the hugeDeviceValidation() test ends up with a few conditions where it would have copied 1 GB of data, so limit that too. We make a choice of reporting OOM vs DataTooLarge only if QByteArray fails to allocate in the first place (QByteArray::resize() -> Q_CHECK_PTR -> qBadAlloc, QtCore is always built with exceptions on). The QCborValue unit test needed a temporary work around until we apply the same allocation fix (see next commit). Pick-to: 5.15 6.0 Fixes: QTBUG-88253 Change-Id: I7b9b97ae9b32412abdc6fffd164523eeae49cdfe Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborStreamReader: move the readStringChunk code to the PrivateThiago Macieira2020-12-051-24/+33
| | | | | | | | | And add a currently-unused QByteArray pointer parameter. This function will resize the array as necessary as data comes in. Pick-to: 5.15 Change-Id: I7b9b97ae9b32412abdc6fffd16451f5c6b280f3b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-4/+4
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Replace qt_make_unique with std::make_uniqueAllan Sandfeld Jensen2020-11-232-11/+8
| | | | | | | We can depend on C++14 now. Change-Id: Iee9796cd22dbfbb70d4bdb25f0eee1662a026d6d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QXmlStream: sanitize input before building a QCharGiuseppe D'Angelo2020-11-181-2/+2
| | | | | | | | | | The result of getChar() may be a combination of a token category and a code unit, like `((LETTER << 16) | c)`. Constructing a QChar out of it requires masking the category out. This was already done in a few code paths but missing in others. Change-Id: I186fb01973a1badd425b3a6811843d8a40b13a6a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CBOR: remove the X11 True and False for goodThiago Macieira2020-11-184-7/+6
| | | | | | | | | | I don't care if you still need X11 headers. If you do, you know your workarounds. Pick-to: 5.15 Fixes: QTBUG-88591 Change-Id: If51855da004b4f3fbf43fffd1648a357eab2d865 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-163-6/+6
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Doc: Add missing brief statements for \property documentationTopi Reinio2020-11-121-2/+2
| | | | | | | | ... where applicable. Fixes: QTBUG-88232 Change-Id: I835df434765caededd35d5114965b4a1663e7942 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QXmlStreamReader: don't store pointersMårten Nordheim2020-11-113-15/+28
| | | | | | | | | | | | | They were pointing into the QHash structure which could be invalidated on insert if growing was needed. This caused some user-after-free issues. Indexing into the QHash is quite fast, so let's just store the name and a pointer to the QHash to do that. Fixes: QTBUG-88246 Change-Id: If7f9b1c6ea7557c5bd0869b42b1b84aa824cc6ce Reviewed-by: Lars Knoll <lars.knoll@qt.io>