summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Fix documentation warningsVolker Hilsheimer2020-10-241-35/+23
| | | | | | | | | Declare hidden friends like qdoc expects them, and other signature fixes Document function parameters Remove documentation for removed APIs. Change-Id: I44c1caeed0d40be04612129d074acc30b75f5259 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix documentation for QVariantRef and QVariantPointerVolker Hilsheimer2020-10-231-10/+10
| | | | | Change-Id: I86b749ec14876df98d5d873cf2274facea49f0c5 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix documentation warnings for QProperty and related classesTopi Reinio2020-10-231-128/+43
| | | | | | Task-number: QTBUG-86295 Change-Id: I547f4cf34d9721f56ba1cd665218f66597ffbb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Deprecate QVariant::TypeLars Knoll2020-10-234-93/+120
| | | | | | | | | 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>
* Do not store non relocatable types in QVariants internal storageLars Knoll2020-10-232-4/+7
| | | | | | | | | | | This mostly reverts change 76e8e8e9c8093f093cb9f37d61d273f43398fefb. The reason is that storing non relocatable types inline in QVariants storage would implicitly make QVariant non relocatable. Fixes: QTBUG-87686 Change-Id: I2a09b1dcdd907d60085dccf17f987086dcba878c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make some QMetaType members constexpr and inlineLars Knoll2020-10-232-35/+35
| | | | | | | | | Since QMetaType::fromType() is constexpr, it makes sense to also make some of it's members constexpr. Change-Id: Ia2d63a904abb680ed63c1f88cb68f1d0309d029c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename the QMetaType::MovableType flag to RelocatableTypeLars Knoll2020-10-232-3/+7
| | | | | | | Keep this in sync with the changes we have done in QTypeInfo. Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QPointer comparisons hidden friendsAllan Sandfeld Jensen2020-10-231-40/+22
| | | | | | | Reduces ADL noise. Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qWaitFor: check predicate before sleepingMorten Johan Sørvig2020-10-221-4/+3
| | | | | | | | | | | | | | | | Return immediately if processing events caused the predicate to become true. This gives us a nice speedup on tests with call qWaitForWindowExposed() or qWaitForWindowActive(), for example tst_QGraphicsView::itemsInRect_cosmeticAdjust: cocoa 1164ms -> 825ms ~30% decrease offscreen 296ms -> 15ms ~95% decrease Change-Id: Ifbab0ca662c082e7dfb609d0cb4bc1161709067b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix documentation for QIterable and related classesVolker Hilsheimer2020-10-231-81/+80
| | | | | | | | Correctly specify template parameters, fix typos, add \fn where missing, explicitly specify scope in see-also references. Change-Id: I8b04a2b76033b206098e816d1d07d105b838c260 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix documentation for hidden friend operatorsVolker Hilsheimer2020-10-233-54/+21
| | | | | | | | At least for qdoc, hidden friends are class members. Change-Id: I6eaa21565937cd49c0905ee47b8b82b0c1765bc1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Make QEvent::setAccepted() virtual; set QEventPoints state the sameShawn Rutledge2020-10-222-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | In Qt Quick, when we deliver an item-specific QTouchEvent that contains only the subset of eventpoints that are inside the Item's bounds, traditionally the Item can accept the event to tell the delivery logic that the event is handled and doesn't need to be delivered further. But an Item cannot be expected to have total scene awareness; so now, the delivery is "done" only when all eventpoints in the original event are accepted. This behavior has been working well enough already due to logic in QQuickWindow that iterates the points and accepts them if the event is accepted; but it seems appropriate to move this enforcement into QPointerEvent itself. Making setAccepted() virtual gives us a useful degree of freedom. Event-handling code should alternatively use QEventPoint:setAccepted() or QPointerEvent::setExclusiveGrabber() to take resonsibility for only a subset of the touchpoints. Another way to put it is that we treat QPointerEvent::setAccepted() as a convenience method: accepting the QEventPoints is what counts (at least in Qt Quick). Change-Id: Icec42dc980f407bb5116f5c0852c051a4521105a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* name our glib event sources to ease debuggingAndreas Buhr2020-10-221-9/+13
| | | | | | | | | | | glib event sources can have a name, but it is not required. Internal to glib, it is common to give them a name, see for example https://git.io/JTZ8g . This patch gives a name to each glib event source created in qtbase. Task-number: QTBUG-84291 Change-Id: I4f04526dcec082242312e3a66da2adf37a22e626 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QEvent copy constructor: copy the type flags tooShawn Rutledge2020-10-211-6/+3
| | | | | | | | | | | | | Failure to copy m_inputEvent and m_pointerEvent actually left them uninitialized, and resulted in random behavior in Qt Quick when Flickable clones a pointer event for later replay. Remove the comment about copying events being a "bad idea" in Qt 4, while we're at it. Copying became more common in Qt 5, and we probably won't be able to stop doing it now. Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qmetaobject_p.h's MetaObjectFlag in QMetaObjectBuilderEdward Welbourne2020-10-203-13/+7
| | | | | | | | This saves duplicating them with its own flags. Task-number: QTBUG-85700 Change-Id: I9e938322fd787282cfd9f941f83af8c0d76aaa9d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QAssociativeIterable: Unwrap variants on value()Ulf Hermann2020-10-191-2/+12
| | | | | | Fixes: QTBUG-87688 Change-Id: I66515eaa1217c34f003648af6423b318b54977c4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QAssociativeIterable: Add methods to add/remove keys and valuesUlf Hermann2020-10-192-0/+60
| | | | | | | | This way we can actually modify the container. Previously the interface was rather useless. Change-Id: I278aae46999862ada115c9066a010d7de5cde4ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaContainer: Consistently coerce typesUlf Hermann2020-10-199-97/+86
| | | | | | | | | | | | | | | The high-level iterable interfaces should coerce the types of most QVariants passed to the expected ones. To do this, move the type coercion code into qvariant.{h|cpp} so that it is available to the QVariantRef specializations. The exception are variants passed to the find() functions of associative iterables. Here, we should not coerce values we cannot convert to the default-constructed keys. Instead we return end() in such cases. Fixes: QTBUG-87687 Change-Id: I0bd4e5c4e4e270dd3bf36cb3fb115794828077f2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProperty: Add value() and setValue() to QBindableUlf Hermann2020-10-191-0/+14
| | | | | | | | This simplifies code that would otherwise need to use the setter and getter in addition to the bindable. Change-Id: Iec6510b4f578f5b223c63b3a0719257a0cf2463d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Core: Make the metacontainer interfaces constexprUlf Hermann2020-10-181-33/+23
| | | | | Change-Id: Ib8e486a855673b191a9854e1c4d62614a2b87e72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make most of QMetaTypeInterface constexprUlf Hermann2020-10-187-68/+86
| | | | | | | | | | | | | | | | | | The only thing we need to modify at runtime is the typeId and that can be mutable. This way we can have a constexpr ctor for QMetaType which hopefully makes the importing and exporting of related symbols less fickle. On Windows we cannot make QMetaTypeForType constexpr as that leads to mysterious errors in other places. Until we figure out why that is, we just leave this class as non-constexpr. This reveals that qcoreapplication.h and qvariant.h are using QDebug without including it. We now get template instantiation errors. Include qdebug.h to avoid that. Change-Id: If1bf0437ada52459c59c6fa45bab3d22dfb0bc92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Refactor QMutexLocker to be able to handle recursive mutexesLars Knoll2020-10-172-4/+4
| | | | | | | | Since we're going to split QMutex and QRecursiveMutex into separate classes, make sure QMutexLocker is prepared for that. Change-Id: Id5e9a955d1db7c8ee663dd3811ad6448dad0aeae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMetaType: Silence float comparison warnings in QEqualityOperatorForTypeUlf Hermann2020-10-161-0/+3
| | | | | | | | We actually do want to invoke the original equality operator there. If that is unsafe, we cannot do much about it at this point. Change-Id: Iadb2eaba1156828d89022d282c41bda57b500b13 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix "variable set but unused" in qvariant.cppUlf Hermann2020-10-161-1/+1
| | | | | | | ... how did that pass the CI? Change-Id: I84baaf3632df0410d1fb25f24fd22f65daae13af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QVariant::compare: handle numerical values and pointers as documentedv6.0.0-beta1Fabian Kosmale2020-10-151-9/+80
| | | | | | | | [ChangeLog][QtCore][QVariant] Comparing two QVariants containing floating point numbers for equality no longer uses fuzzy comparisons. Change-Id: Iaba40a66d8fa566a432547fa1a30d5ea191c7fc0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix compile time type normalization codeLars Knoll2020-10-141-81/+146
| | | | | | | | | | | | | | | | | | | | | Use a simpler constexpr to generate type name on gcc This works around an ICE on gcc in release mode when compiling with PCH enabled. As the type we're getting from Q_FUNC_INFO is already in a somewhat normalized form, this requires significanlty less processing and esp. not a recursive constexpr method which I suspect triggers the ICE. Fix integer type conversions to also properly normalize long long values (to q(u)longlong. Make sure the mapping also works on MSVC, where long long types get mapped to __int64. Also, normalize unsigned short and unsigned char to ushort and uchar, respectively, to follow the convention set by uint and ulong. Add some test cases to verify the mappings. Change-Id: I3dec5764450bf22ab6f066597803c3f46c2cd5ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QMetaType: fix warning messageFabian Kosmale2020-10-141-1/+1
| | | | | Change-Id: I93c8b0d6b490cfed944a2a6a2b64361258a50141 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live Q_IMPLICIT!Giuseppe D'Angelo2020-10-141-3/+3
| | | | | | | | | | | | | 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>
* Remove nodiscard in QPropertyObserverNodeProtector ctorAndrei Golubev2020-10-131-1/+1
| | | | | | | | | Produced error in my GCC 7.5 on Ubuntu 18: error: ‘nodiscard’ attribute applied to ‘QPropertyObserverNodeProtector<<anonymous> >::QPropertyObserverNodeProtector(QPropertyObserver*&)’ with void return type [-Werror=attributes] Q_REQUIRED_RESULT QPropertyObserverNodeProtector(QPropertyObserver *&observer) Change-Id: Ic1f6c4f502bb4d5c764686d5521b92f655592bb2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* doc: Add brief and group for native type conversionsTor Arne Vestbø2020-10-131-93/+153
| | | | | Change-Id: I74608619201bf77e487fb986bf213b349cc22f6a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Mark the class QPropertyObserverNodeProtector as [[nodiscard]]Lars Knoll2020-10-131-1/+1
| | | | | | | And not its constructor, as GCC at least doesn't like that. Change-Id: I4aada7ca7135dd9c599980640588e7c98d398171 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QObject: simplify part of connection logicFabian Kosmale2020-10-131-16/+3
| | | | | | | | | | | We do not require anymore that the metatypes are declared beforehand, but can instead simply use QMetaType::fromType<T>().id(). This allows us to remove the templates containing the "metatype is declared" validation logic. Change-Id: I0b74c72643a233335689074091a38648f3e4f853 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qDebug: Avoid implicit QVariant conversionFabian Kosmale2020-10-132-8/+11
| | | | | | | | | | | | | | | | | | | | | | | This commit restricts operator<<(QDebug lhs, QVariant rhs) to only work if rhs is actually of type QVariant (instead of any type convertible to QVariant). This is especially important as a) we check in QMetaType whether (slightly simplified) QDebug{} << std::declval<T>() is valid, and if so, register a function which simply uses the operator. b) In QVariant, we ask the metatype system for the contained types registered debug function and then use it. If a type now does not have its own operator<< for QDebug, but is implicitly convertible to QVariant containing itself, this would lead to an infinite recursion, when trying to use qDebug with that type. The registered function in a) would just convert the type to QVariant, and then ask the QVariant to print itself. Disallowing implicit conversions in qDebug in general was considered (i.e. adding template<typename T> operator<<(T) = delete in QDebug ), but discarded as it breaks too much code relying on conversions. Fixes: QTBUG-87122 Change-Id: Ib709297670cbc6cc307efd0dfd8e5b0279df9414 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaType: Avoid combination of extern and declspec(__dllexport) on MSVCUlf Hermann2020-10-122-5/+19
| | | | | | | | | MSVC does strange things with this, and it actually tells us so via a warning. We can, however, attach the dllexport to the definition, rather than the declaration of the symbols in order to resolve the problem. Change-Id: I9971e13afc6d8840c49ec20d21820a72c5407200 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QPropertyBinding: compare QMetaType directlyFabian Kosmale2020-10-121-1/+1
| | | | | Change-Id: I36fbc8ebed096aa6f7be48456005395b65229359 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QPropertyObserver: mark as noexcecptFabian Kosmale2020-10-122-4/+4
| | | | | Change-Id: I2df75b35e42fa923c6cbf71a15569dc37140ee55 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QUntypedPropertyBinding::QUntypedPropertyBinding: use member initializer listFabian Kosmale2020-10-121-1/+1
| | | | | | | No need to default initialize the std::function and source location. Change-Id: I7d840376b16e7257386a4787dd06b7956fe37576 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QProperty: avoid needless std::function copyingFabian Kosmale2020-10-122-2/+2
| | | | | Change-Id: Iea6280b12e7146a9ac92f071a4c21b373e9d3ab0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QProperty: make a few helpers constexprFabian Kosmale2020-10-122-2/+2
| | | | | Change-Id: I1f3b2223530c311a7b40fd36c8162e32adbd9569 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Handle notifier list modification during iterationFabian Kosmale2020-10-123-25/+135
| | | | | | | | | | | | | | As propertyobservers can execute arbitrarily complex code, they can also modify the obsever list in multiple ways. To protect against list corruption resulting from this, we introduce a protection scheme which makes the list resilient against modification. A detailed description of the scheme can be found as a comment in QPropertyObserverPointer::notify. Task-number: QTBUG-87153 Change-Id: I9bb49e457165ddc1e4c8bbdf3d3c9fbf5ff27e94 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPropertyChangeHandler: mark as nodiscardFabian Kosmale2020-10-121-1/+1
| | | | | Change-Id: Ibf399b5aac732e8f80d0a37df711806c1c5550ac Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Allow getting a const pointer out of a variant containing pointerFawzi Mohamed2020-10-081-0/+7
| | | | | | | | | | | | | Currently A a; QVariant::fromValue(&a).value<const A*>() == nullptr; Still casting non const to const is safe, and worked in Qt5. After this change A a; QVariant::fromValue(&a).value<const A*>() == &a; Change-Id: I257049d084c712b00a338a2943d379aa478e0981 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compilation on MSVC with /std:c++latestLars Knoll2020-10-081-6/+1
| | | | | | | | | | Inline the definition of QMetaTypeForType::name and make it constexpr. The old code was conflicting in it's definition (only const in the declaration, constexpr in the definition), something MSVC didn't like. Fixes: QTBUG-87225 Change-Id: I7182c421c9f7612e4ff3d538829b2daee0fe4c5c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-079-19/+19
| | | | | | | | | 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>
* Cleanup the comparison operators for QVariantLars Knoll2020-10-071-37/+5
| | | | | | | | | The code was designed to avoid implicit casts when none of the two types was a QVariant in C++98 times. This can nowadays be achieved in a better way by making the operators hidden friends of QVariant. Change-Id: I836b44027fc4ed2bfec401e94d41bddf865c431d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* macOS: Remove dead event type MacGLClearDrawableTor Arne Vestbø2020-10-062-2/+0
| | | | | Change-Id: If35f3e2a67b94e403210c564bf337b54d621f8c5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Convert a couple of APIs to use viewsLars Knoll2020-10-061-1/+1
| | | | | | | | | | | 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-036-40/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QAppleLogActivity: add a swap() methodGiuseppe D'Angelo2020-10-031-0/+6
| | | | | Change-Id: Id698d71fbadf5bd0301a346b3216847d0b2f0b54 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>