summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* General cleanup of qshareddata.hAllan Sandfeld Jensen2020-10-142-134/+135
| | | | | | | | Update the code to something more modern and make the two types more consistent. Change-Id: I524d33fea158e2ba7079fe836164eec03c45649b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Long live Q_IMPLICIT!Giuseppe D'Angelo2020-10-141-2/+2
| | | | | | | | | | | | | C++20 will give us explicit(bool). While we can't use it just yet in its full potential, we can introduce a macro to start marking our implicit conversions (aka `explicit(false)`), removing the need for /* implicit */-like comments. Port a few usages to it. Change-Id: I336d5e4c8d51d8329627900d1059e59062c5cafd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix detach on bool check of QSharedDataPointerAllan Sandfeld Jensen2020-10-131-0/+1
| | | | | | | | | We have a conversion to T* which would be triggered for a non negated bool check. Pick-to: 5.15 Change-Id: I543c66de6b4da64a3a63ee9a438fab6adcc58052 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve QRectF::toRect()Allan Sandfeld Jensen2020-10-121-1/+8
| | | | | | | | | Implement the better rounding mechanism that was previously blocked by requiring C++14 to be constexpr. Change-Id: I4e5b179ce0703f5c0b41c3f0ea00d28dfe53740c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup qshareddata.h noexcept statusAllan Sandfeld Jensen2020-10-111-46/+44
| | | | | | | Set noexcept on functions where it applies. Change-Id: I5efa632bd1652e1215e9c6d3b06dc40c948420d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Disable spurious warning with gcc 9.3Paul Olav Tvete2020-10-091-0/+5
| | | | | | | | | | | | gcc 9.3 gives a warning when compiling with -O2: ‘strlen’ argument missing terminating nul [-Werror=stringop-overflow=] This seems to be caused by a gcc bug that is not present in gcc 8 and fixed in gcc 10: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490 Change-Id: Ice3c18efb7a41097521ecee22d060f175083c579 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Make QADP capacity functions use qsizetype instead of size_tAndrei Golubev2020-10-083-18/+18
| | | | | | | | | | | | | | | Change types returned and accepted by capacity-related QArrayDataPointer functions to qsizetype: 1) QArrayData (underlying d-ptr) works with qsizetype 2) QArrayDataPointer::size is of type qsizetype 3) All higher level classes that use QADP (e.g. containers) cast capacity to qsizetype in their methods Additionally, fixed newly appeared warnings through qtbase Change-Id: I899408decfbf2ce9d527be7e8b7f6382875148fc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-072-4/+4
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix build with g++ 10.2Andreas Buhr2020-10-061-1/+3
| | | | | | | | | | | | g++ 10.2 complains here that a comparison of "Last" with "std::numeric_limits<quint8>::max()" is always false when "Last" is an int greater than 256. This is because "std::numeric_limits<quint8>::max() returns an quint8. Since parts of Qt are built with -Werror, the build fails. Fixed by adding a unary plus (+). Change-Id: I16a6b9f6952aeddf0a2a04d87746e433927122bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Streamline the template specialization of QESDP's dtorGiuseppe D'Angelo2020-10-051-0/+26
| | | | | | | | | | | | | | | | | | | | | Declaring and implementing out of line a specialization for QESDP's destructor is needed if we have an implicitly shared type and we want to provide an inline move constructor for it. The code is however a bit heavy on the eyes, and the full implementation for the destructor must be provided (read: copy and pasted) -- the specialization destructor cannot just "reuse" the one from the primary template. This patch adds a few macros to streamline the above, so that we can start using the same pattern in more places. These macros are completely private for the moment being; we don't want to push this solution for our users. Port QPixmap to the new macros. Change-Id: Ia6a51ad988483e44c9d97c0eca2fb003b6bd21e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Do not use QHash's aeshash() under Clang's sanitizerAndrei Golubev2020-10-051-2/+14
| | | | | | | | | | | | | | | | | | | aeshash() has a heap-buffer-overflow when the passed in buffer length is less than 16 bytes (and I expect there's a similar issue when we process the tail when length is not divisible by 16). Despite being a real issue, the code has guarding mechanisms to make sure that: 1) no crash happens 2) out-of-range bits are not used in the computation Disabled the usage of aeshash() under Clang's sanitizer similarly to how it was done for GCC (apparently it uses its own preprocessor mechanism). Likely, this will pop up again with MSVC, but I have no clue which defines it uses Task-number: QTBUG-87112 Task-number: QTBUG-86051 Change-Id: I614d7b3082e91c9d16e0441649d6a153b222bd2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-0310-51/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix qdoc warnings for QMap/QMultiMapVolker Hilsheimer2020-10-013-81/+79
| | | | | | | | | | | | | | | | | | | | | | | | These containers have most of their operators as non-members, except those declared as hidden friends in the iterator classes, which will be fixed in qdoc. QMultiMap doesn't have an operator[] (which might be unintentional). Deprecate QMultiMap::insert/insertMulti APIs, as the documentation suggests that those are just compatibility overloads. Add documentation for the rvalue-overload of QMap/QMultiMap::insert. Note that this overload does not exist for QHash/QMultiHash. Also, it seems from the implementation that the moved-from map is not reset to the empty map if it did share data with another copy. Not addressed: QMap and QMultiMap have the special 5 implicitly generated by the compiler, so these functions are not declared anywhere, which results in qdoc warnings. qdoc could generate the documentation automatically, if it can know that those members exist. Change-Id: I0608b57c8c3793fedd304a4c7b10e607a24ad5f6 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Deal with {und,ov}erflow issues in QLine's length handlingEdward Welbourne2020-09-302-23/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use std::hypot() instead of sqrt() of a sum of squares. This ensures length() can't be zero when isNull() is false. Use length() in QLine::setLength() rather than duplicating that. Clarify and expand some documentation; isNull() never said what constituted validity, nor did unitVector() mention that is should not be used on a line for which isNull() is true. Make clear that lines of denormal length cannot be rescaled accurately. Given that we use fuzzy comparison to determine equality of end-points, isNull() can be false for a line with displacements less than sqrt(numeric_limits<qreal>::denorm_min()) between the coordinates of its end-points (as long as these are not much bigger); squaring these would give zero, hence a zero length, where using hypot() avoids the underflow and gives a non-zero length. Having a zero length for a line with isNull() false would lead to problems in setLength(), which uses an isNull() pre-test, protecting a call to unitVector(). (It was already possible for a null line to have non-zero length; this now arises in more cases.) Restored QLine::setLength() to the form it had before a recent change to avoid division by zero (which resulted from underflow in computing the length of a non-null line) but allow for the possibility that the unit vector it computes as transient may not have length exactly one. Add tests against {ov,und}erflow problems in QLine. Reworked the test added during the divide-by-zero fix to make it part of the existing test. Pick-to: 5.15 5.12 Change-Id: I7b71d66b872ccc08a64e941acd36b45b0ea15fab Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
* QList: don't detach on squeeze when holding raw dataMårten Nordheim2020-09-301-1/+3
| | | | | | | | | To match QString and QByteArray behavior Change-Id: Ifce4a5dee6fc9077e855a24499f11f911e359cf5 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: Remove CapacityReserved on squeezeMårten Nordheim2020-09-301-0/+3
| | | | | | | | | | Even if we don't reallocate or detach. Change-Id: I44928c261f037b304de8ee6135b96f00dd217c51 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Remove workaround for MSVC 2008Allan Sandfeld Jensen2020-09-302-82/+8
| | | | | | | We don't build on platforms without stdint.h Change-Id: Iee9de3e71a7bcae524f2d1377919cf074a713960 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix ubsan errorsAllan Sandfeld Jensen2020-09-301-0/+6
| | | | | | | | Nullptr memcpy, memmove and 36 bit shift of integer. Change-Id: Ib79c8a98a710d021fc93b6aaec6c0ba9bde5f91e Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Switch QBitArray to qsizetypeAllan Sandfeld Jensen2020-09-293-96/+96
| | | | | | | To make it consistent with other containers in Qt6. Change-Id: I5578845390248baf80daa282237b706857e57661 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Switch QCache costs to qsizetypeAllan Sandfeld Jensen2020-09-292-24/+24
| | | | | | | | Since size is already qsizetype and costs is multipla of size, it seems costs should be qsizetype as well. Change-Id: Iae85baaba5842460358e369a666fef6ebb7e52b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some qdoc warnings from QHash and QMultiHashVolker Hilsheimer2020-09-281-21/+8
| | | | | | | | | | | | | | It's no longer possible to decrement an iterator, and the class uses qsizetype, not int for sizes. Fix incorrect function prototypes in the documentation, and remove documentation for functions/overloads that don't exist. QMultiHash doesn't have Java style iterators (not a new issue in Qt 6), so remove the references to QMultiHashIterator. Change-Id: I149b4620963f2087f3f66bb70a9c97b292a35378 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-2510-93/+80
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QScopedValueRollback: code tidiesGiuseppe D'Angelo2020-09-251-5/+7
| | | | | | | Add constexpr + deploy std::exchange. Change-Id: I4c5e6f5d35cd74c464667f633344d27c0656f0eb Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Documentation: purge QSet and QHash members that no longer existVolker Hilsheimer2020-09-232-433/+54
| | | | | | | | | | | | QMutableSet/HashIterator can not walk backwards, neither can the STL iterator. When function documentation was shared with other iterator types, move it into separate section to avoid linking to incorrect see-alsos. Remove or fix other member function documentation that had errors, e.g. in parameter types after move to qsizetype. Change-Id: Ic7f97a295eff63ee748998b10f08a160706fa650 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some qdoc warnings: function names in "see also"Volker Hilsheimer2020-09-221-4/+4
| | | | | Change-Id: I6b2b444ccc4de6629d800933802ffa8f75682b96 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix various qdoc warningsVolker Hilsheimer2020-09-221-2/+2
| | | | | | | Parameter types and names, missing enum values, and \since 6.0. Change-Id: I1b028fcf2ef0b57accb1ef7cebf17dab9f6d571e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix some qdoc warnings: typos and qdoc syntaxVolker Hilsheimer2020-09-221-2/+2
| | | | | Change-Id: Idf5c1490330e0f2e5d4bcf920eb03fc9993b3c8a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove some deprecation comments from qmap.hEdward Welbourne2020-09-212-7/+5
| | | | | | | | | Lars says documenting that the methods are slow is sufficient, no need to deprecate them. Task-number: QTBUG-85700 Change-Id: I7b1d19e91e30205df7d8198e3704cecc72a853e0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Define inverted QRects consistentlyAllan Sandfeld Jensen2020-09-212-84/+100
| | | | | | | | | | | | | | | | Changes the definition of invalid QRects to be more consistent. This simplifies the logic, and makes it possible for us to fix normalized() so dimensions don't change. The actual API is not changed except for inverted rects. Only one use-case for the old normalized() function existed, and has been reimplemented as QRect::span(). Fixes: QTBUG-22934 Change-Id: I29dad2952dc6c8e84a6d931898dc7e43d66780f3 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update QList's documentation relevant to prepend optimizationAndrei Golubev2020-09-211-38/+65
| | | | | | Task-number: QTBUG-84320 Change-Id: I550f9dd7810855df0b0cc2bcbc78a97d6abaac7a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix a bunch of qdoc warnings from QList typesVolker Hilsheimer2020-09-212-0/+11
| | | | | | | | | | For documentation purposes, we treat QList, QByteArrayList, and QStringList as simple classes, whereas reality is a bit more complicated. We conditionally change the declaration of the types for qdoc runs, and need to be consistent to avoid a flood of warnings from clang when building documentation. Change-Id: I22d529079e10f8fd3d93edc771e5f05729fa925f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Rename QVarLengthArray's private realloc() to reallocate()Jesko von Monkiewitsch2020-09-191-8/+8
| | | | | | | | | | | | | This will enable run-time debugging on Windows, using _CRTDBG_MAP_MALLOC, which uses #define to override the standard library memory management functions, including realloc. Fixes: QTBUG-86395 Change-Id: I51975dd74cab0ae8309436c86d17a59074c561e1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Rename size parameter to QCommonArrayOps::sizeToInsertAtBegin()Ulf Hermann2020-09-161-8/+8
| | | | | | | | | ... in order to avoid a bogus compiler warning. Change-Id: I25eb435d6d57bdd5ef5c05ccacb0e6413631f6c9 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Only include <bit> if using post C++17Allan Sandfeld Jensen2020-09-151-1/+1
| | | | | | | Otherwise we hit an #error statement in MSVC standard library. Change-Id: Ib029edf0be8513a80f2640fd9ca75541615a0448 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add qHash implementation for QPointMitch Curtis2020-09-152-0/+15
| | | | | | | | | [ChangeLog][QtCore][QPoint] Added qHash() implementation. Change-Id: I65332e7aafab53af40a6e11457b9b457196d584c Fixes: QTBUG-86457 Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use universal C++20 bit operations when availableAllan Sandfeld Jensen2020-09-131-17/+49
| | | | | | | Avoids using compiler builtins, and can in future replace them. Change-Id: I3f0afe7d28b6ba05bcd1c1132b44a8db7b182d8a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QStringList an alias to QList<QString>Lars Knoll2020-09-122-17/+28
| | | | | | | | | | | | | | | | | | Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix generated forward declarations in qdbusxml.cppLars Knoll2020-09-121-0/+4
| | | | | | | Simply use qcontainerfwd.h, instead of declaring those manually. Change-Id: I6d87bf14b60469b457e8e9335868f8cdb0303817 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix possible corner cases in qarraydataops.hAndrei Golubev2020-09-101-9/+11
| | | | | | | | | | | | | | | Updated moveNonPod function to behave correctly under exceptions being thrown. This is the version that was implemented at some point but then got changed prior to merge. Added tests for moveInGrowthDirection (which uses moveNonPod in general case) to verify that range movements are correctly done Updated QCommonArrayOps access modifier from private to protected to allow testing of internal stuff by subclassing Task-number: QTBUG-84320 Change-Id: Idb994a72ee601762e32248670cdc7819aaca0088 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make Q*ArrayOps erase aligned with std::vector::eraseAndrei Golubev2020-09-101-5/+5
| | | | | | | | | | | Scoped GrowsBackwards-optimized erase to only be applied when erase starts at the beginning of the element range. In other cases, old "left-shifting" erase is used to align with std::vector::erase invalidation policy Task-number: QTBUG-84320 Change-Id: I2e7f3b96b056bc371119eb2d36cc7c74af52c394 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommonArrayOps: append when inserting into empty containerAndrei Golubev2020-09-071-3/+3
| | | | | | | | | | | Ensured append is chosen instead of prepend for corner cases when inserting into an empty container Mirrored the logic in shouldGrowBeforeInsert function Task-number: QTBUG-84320 Change-Id: I1c963a2588c331029e450fe55001bbf324f65fb4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QList/QString/QByteArray: no prepend optimized allocation when emptyAndrei Golubev2020-09-071-4/+3
| | | | | | | | | | | | | | | | | | Scoped prepend optimized allocation to only work when prepending into a non-empty container. Otherwise, even appends would be considered prepends since d.size == 0 when container is empty This is, of course, not good for prepend cases but we prefer appends over prepends. My proposal is to figure out what's the best strategy based on use cases and performance measurements. For now, let's just make sure appends are not additionally pessimized Anyhow, this is an implementation detail and should not be considered behavior change (at least not the one that is user noticeable) Task-number: QTBUG-84320 Change-Id: Ibed616a2afa9bc24f78252f15a617bf92e2c6ea3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update QList's documentation bitsAndrei Golubev2020-09-071-44/+43
| | | | | | | | Fixed some QList documentation that described old API/behavior Change-Id: I9101ebb7bed9bcac328509765f8e9b85d63d305b Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Get rid of the MSVC specific fileLars Knoll2020-09-052-54/+0
| | | | | | | | | It used to contain the MSVC specific export hack for QVector, but that one is not required in Qt 6 anymore and the file was not doing anything anymore. Change-Id: Ic8b4aa355a8934beb6abcf10235d218344a294cc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList/QByteArray/QString: Base GrowsBackwards heuristic on old sizeMårten Nordheim2020-09-031-2/+2
| | | | | | | | | | | If you grow from 10 to 100 characters then even if the point of insertion was the end then it will get the GrowsBackwards option on realloc. By basing it on the oldSize the intention of the position to insert at is better clarified. Change-Id: Ia73f4902e8356d94709556de5704cbfa0e1a3a56 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 via P1120 is deprecating arithmetic operations between unrelated enumeration types, and GCC 10 is already complaining. Hence, these operations might become illegal in C++23 or C++26 at the latest. A case of this that affects Qt is in key combinations: a QKeySequence can be constructed by summing / ORing modifiers and a key, for instance: Qt::CTRL + Qt::Key_A Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below) The problem is that the modifiers and the key belong to different enumerations (and there's 2 enumerations for the modifier, and one for the key). To solve this: add a dedicated class to represent a combination of keys, and operators between those enumerations to build instances of this class. I would've simply defined operator|, but again docs and pre-existing code use operator+ as well, so added both to at least tackle simple cases (modifier + key). Multiple modifiers create a problem: operator+ between them yields int, not the corresponding flags type (because operator+ is not overloaded for this use case): Qt::CTRL + Qt::SHIFT + Qt::Key_A \__________________/ / int / \______________/ int Not only this loses track of the datatypes involved, but it would also then "add" the key (with NO warnings, now its int + enum, so it's not mixing enums!) and yielding int again. I don't want to special-case this; the point of the class is that int is the wrong datatype. Everything works just fine when using operator| instead: Qt::CTRL | Qt::SHIFT | Qt::Key_A \__________________/ / Qt::Modifiers / \______________/ QKeyCombination So I'm defining operator+ so that the simple cases still work, but also deprecating it. Port some code around Qt to the new class. In certain cases, it's a huge win for clarity. In some others, I've just added the necessary casts to make it still compile without warnings, without attempting refactorings. [ChangeLog][QtCore][QKeyCombination] New class to represent a combination of a key and zero or more modifiers, to be used when defining shortcuts or similar. [ChangeLog][Potentially Source-Incompatible Changes] A keyboard modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using operator|, not operator+. The result is now an object of type QKeyCombination, that stores the key and the modifiers. Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QString/QList: disregard space at front during reserve()Andrei Golubev2020-09-021-2/+2
| | | | | | | | | | Aligned QString, QList to the new agreed upon behavior Aligned QList::resize() along the way to be consistent with QString/QBA Task-number: QTBUG-84320 Change-Id: Ie9d7b4b6ebe54bd373af78d92906144b383bbfe2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix an annoying compiler warning on MSVCLars Knoll2020-09-021-1/+1
| | | | | | | | Fix a warning about truncating a const through a static_cast on MSVC. Change-Id: I381ce806d602c006ef6f14eb4fc89716bc5403ae Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix include style violation in qline.hFriedemann Kleint2020-09-021-1/+1
| | | | | | | | Amends c0d0949448c5a75d50ca189974d4d9f48133aea8. Pick-to: 5.12 5.15 Change-Id: Ie220a245ae2000af6e52c000c6836b9830c56de6 Reviewed-by: hjk <hjk@qt.io>
* QWeakPointer: purge deprecated APIEdward Welbourne2020-08-311-23/+0
| | | | | | | | Since 5.0: assignment/construction from QObject pointer Since 5.14: data() to recover the packaged pointer Change-Id: I5d6ab561ce39bc0d9d3e5035eb2ca38139cd76b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>