summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Clean up qcontainerfwd.hLars Knoll2020-11-032-8/+0
| | | | | | | | | | | | Add missing declaration of QVariantList and friends. Replace class with typename for template parameters. Remove some left-over forward declarations in other headers. Change-Id: I31d443019d48b619e02834395dafa40182cac7b9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate QVariant::TypeLars Knoll2020-10-233-4/+4
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Cbor: Export the datastream operators for QCborSimpleTypeUlf Hermann2020-10-181-2/+2
| | | | | | | | Otherwise they are not available to the tests. This is exposed by making the metatype interfaces constexpr. Change-Id: I1b3214f339985f2f8ffaf0640cf51e41e92198d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QCborValue: streamline some code with qExchangeGiuseppe D'Angelo2020-10-131-3/+1
| | | | | Change-Id: I79b68173a236ff1f28504a11ff182bdf48b2df0b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix use of \inheaderfileTor Arne Vestbø2020-10-071-1/+1
| | | | | | | Pick-to: 5.15 Pick-to: 5.12 Change-Id: Ib969d6cf23b874e873cfc82b1b19dff2a4fe5f8f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Convert a couple of APIs to use viewsLars Knoll2020-10-065-11/+11
| | | | | | | | | | | Try to get rid of APIs that use raw 'const {char, QChar} *, length' pairs. Instead, use QByteArrayView or QStringView. As QStringConverter is a new class, simply change the API to what we'd like to have. Also adjust hidden API in QStringBuilder and friends. Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Q_DECL_UNUSED with [[maybe_unused]]Allan Sandfeld Jensen2020-10-032-3/+3
| | | | | | | Use C++17 attribute directly Change-Id: Id853e7a5117065e4adb549f81303c1820fe198ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-031-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>