summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* MinGW: Fix assert in QCoreApplication::arguments() when passing globsTor Arne Vestbø2020-10-291-24/+39
| | | | | | | | | | | | | | | | | | | | | | | | | We can't assume that the number of arguments we get from GetCommandLine will match what we have from argc, as the former is not wildcard expanded on MingGW. mingw64 will ask __getmainargs to expand wildcards depending on the mingw-specific variable _dowildcard. By default this is set to 0 (false), but some mingw64-packagers (msys2, mingw-builds) pass --enable-wildcard during build, changing this default. As a result, the arguments we get through argc/__argc have already been expanded. MinGW does not reflect this through GetCommandLine though, like MSVC does, which triggered the assert. Amends dff18b8e80609da91bf9e9134967dcf0d23eca9e. Pick-to: 5.15 Fixes: QTBUG-67515 Task-number: QTBUG-84002 Change-Id: Ib87961c6901d2894b48ba0f5b9a3d6da2a595f24 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Simon Hausmann <hausmann@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QMetaMethod: Make comparison operators hidden friendsVolker Hilsheimer2020-10-292-11/+6
| | | | | | | Reduce ADL noise. Change-Id: Ic747c2d76b7ce66b222e08eeaf6f1d193ba99f81 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Always return initialized data from QBindable::valueVolker Hilsheimer2020-10-281-3/+5
| | | | | | | | | | | | clang warned about result being uninitialized if iface is nullptr. Return a properly initialized result in that case as well. This might break RVO, but the alternative is to always initialize result, even if we are going to call the getter anyway, which I assume would be more expensive. Change-Id: I5d6d243b3094b79bf021725d017be5c72b1089bb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Revert "QObject: simplify part of connection logic"Fabian Kosmale2020-10-271-3/+16
| | | | | | | | | | | | | | | This reverts commit 1918c689d78b0f6a718343e7ebceb387acc32a97. The template gets always instantiated in QObjectPrivate::connect, even if the connection types is not Qt::(Blocking)QueuedConnection. For non-queued connections we however support using incomplete types in connect. The only way to fix this would be to make the connection type a template parameter of QObjectPrivate::connect (or at lesat pass some compile time constant indicating "blocking"-ness) along, so that we can use if constexpr instead of if. As all involved classes are private, we can postpone investigating this solution to 6.1 Change-Id: Ieffaf015f8e60ca6ac6f85eb9e2756e480060b4f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make QElapsedTimer comparison operators hidden friendsVolker Hilsheimer2020-10-273-20/+20
| | | | | | | | | Reduce ADL noise. Clean up documentation and parameter naming a bit, while at it. Change-Id: Ie9eb2a63b8e87a9ffc019b8fff5bd1c6bafaaf43 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Document QVariant::data/constDataVolker Hilsheimer2020-10-261-2/+12
| | | | | | | | | QMetaSequence refers to those members, and QMetaType operates on void*s, and documents such low-level APIs as well, so can't think of a reason why we should not document the QVariant getters as well. Change-Id: Id18de839bb0e4f5559b28bfca80eaabab1eb6479 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Whitespace cleanup in corelib/kernelAllan Sandfeld Jensen2020-10-2437-344/+359
| | | | | Change-Id: If061ef0af5ced4384e20a82afcea3712fa7e45d7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* 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>