summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Notify socket notifier on connection error6.0Morten Johan Sørvig2021-07-021-3/+11
| | | | | | | | | | | | | | Enable kCFSocketConnectCallBack to get connection made/failed notifications. For the error case, the data pointer will be set (it points to an int with the error code). Change-Id: Ib51c0ae7c2c74d7bc2fea3c8b7aa9033a860f602 Fixes: QTBUG-91619 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit d492245d9f98e410e1748f28a598945244dbafa8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* fix: The QtStartUpFunction function may be called repeatedlyJiDe Zhang2021-04-281-1/+9
| | | | | | | | | | Don't call pre routine function in qAddPreRoutine if the qt_call_pre_routines is not called Task-number: QTBUG-90341 Change-Id: I0ee70561dc57b857f8b3b1cf42c9dfe0cf45bd49 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 22e967c3049608f82abd32a0beb0b4b36ee134bf)
* Fix build error on iOS with the configure option -qtnamespaceLars Schmertmann2021-04-272-3/+9
| | | | | | | | | | | | | qtbase/src/corelib/kernel/qsharedmemory_p.h:62:33: error: unknown type name 'QString'; did you mean 'XXXX::QString'? int createUnixKeyFile(const QString &fileName); ^~~~~~~ XXXX::QString Change-Id: I455526503f059efc2f496b159b4cb098385dda00 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit d81a9206ac528ad7b5093305d7fe0037053468b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QEventDispatcher(Win): Always honor interrupted status to avoid racesMårten Nordheim2021-03-251-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | There may be a race where e.g. thread 'B' is woken up by a queued invoke. At the same time thread 'A' asks 'B' to quit, which will set various atomics (some important ones are 'interrupt' in the dispatcher and 'exit' in the event loop), but it does _not_ try to send another wake since there is already an unhandled wake triggered by 'B' itself. Sadly 'B' reads the 'exit' atomic before 'A' updates it. Then, slightly before, 'B' sets 'interrupt' back to 0, 'A' write 1 to it, meaning 'A's interrupt is ignored. Then, since there is no interrupt, 'B' goes back to waiting for events, leaving the thread alive and running instead of quitting. Maybe this has unforeseen consequences (one consequence is that it will return and re-enter the event dispatcher once more, possible unnecessarily) Fixes: QTBUG-91539 Change-Id: Ie6f861f42ffddf4817d5c8af2d764abe9d9103c2 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f274f91cebb0a4fd2ebe37bb3a605c47d6acd404) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add documentation for Q_OBJECT_BINDABLE_PROPERTYAndreas Buhr2021-03-061-0/+23
| | | | | | | | | | | | | | | | The duo Q_OBJECT_BINDABLE_PROPERTY and QObjectBindableProperty can only be documented together. The documentation is now with QObjectBindableProperty. This patch adds a documentation entry for Q_OBJECT_BINDABLE_PROPERTY which links the user to QObjectBindableProperty. Task-number: QTBUG-90511 Change-Id: I9af4a99d49f4b02ee9645a2cc9a9a024a6a1a552 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 89cc39a894dddaa0347ecf08438ea31b4880961c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Mark QPropertyAlias as internalFabian Kosmale2021-02-161-0/+2
| | | | | | | | | | That class was only really meant for the QML compiler, and it is dubious if event that one needs it. The current implementation is also broken. Change-Id: Ie40d282707f3fabc8079bee9e98f082aeb9d30b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 5481601debd6ce06bb8f0135e3ea4baf8a21cb3d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add new special QObjectPrivate::{connect, disconnect} for QMLAndrei Golubev2021-01-212-3/+52
| | | | | | | | | | | | | | | | | Original QML-specific connection mechanism ignores the receiver argument and uses sender as receiver. This causes uncontrollable memory growth in certain cases as connections on receiver persist even after receiver is destroyed New connect() with receiver parameter uses underlying API correctly, disconnect is provided for the symmetry (not sure it's really needed) Task-number: QTBUG-86368 Change-Id: I4580d75b617cb2c4dfb971a4dfb8e943e325572b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 6f520abdab7120789800208dde837b3836f762cc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add missing since to QEvent::copy docsNicolas Fella2021-01-191-0/+1
| | | | | | | Change-Id: Idfadc1801b0e97a5030d2784a65ae658900efd12 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 9b2df27bb3a5e8fb788f7274013aa66d32d1250d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Clarify setLibraryPaths behaviorPaul Wicking2021-01-191-3/+4
| | | | | | | | Fixes: QTBUG-89130 Change-Id: Id8460fd00dcfdcca174d523f8d97baef1a764f6f Reviewed-by: Topi Reiniö <topi.reinio@qt.io> (cherry picked from commit efa5a699729c6ff9f9d7991d12ed70139e3be669) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty docs: update macro nameAndreas Buhr2021-01-081-4/+5
| | | | | | | | | | | Use Q_OBJECT_BINDABLE_PROPERTY instead of non-existing ones. Follow-up to 50e1976437f645e9d6571d4498e9d44388e59c19. Task-number: QTBUG-85520 Change-Id: I138f0775d9804029f2ecd6bd3594ab47b247392e Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 618dd6b5a7ed3e9933b3f3a8bf3429caf2506319) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix segmentation fault in QObject::dumpObjectInfoAndreas Buhr2021-01-071-1/+1
| | | | | | | | | | | | | There was a check "if (cd && cd->signalVectorCount())" in the code which was faulty because "signalVectorCount()" could return -1 to indicate that no signalVector is available. This patch fixes the problem. Fixes: QTBUG-89846 Change-Id: I12c512ff8d889ba2bd298789ab6081930f739089 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 6a664d0660911173c7e85c60b9af195a0ef4f110) Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Disallow construction of QPropertyBinding from a propertyFabian Kosmale2020-12-181-5/+1
| | | | | | | | | | | | | | | | | | | | | | This would steal an existing binding from a property, which is most likely not the intended action. Alternatively, we could make it equivalent to Qt::makePropertyBinding(foo), but that conflates properties with bindings to it. On the other hand, this would avoid a potentially source-breaking change. [ChangeLog][Potentially Source Breaking Change] It was possible to create a QPropertyBinding from a property; this would steal any set binding from the property or create an invalid binding if none was set. Use makePropertyBinding if you want to to create a binding which depends on the property's value, or takeBinding if you want to repurpose the property's binding. Fixes: QTBUG-89507 Change-Id: Icd2d3b9261b60f36948f2cea9c33ddbea36efbc1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit c88905f0a947d59c61d9f0f990354ca935d3d4ed) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty docs: update macro nameIvan Solovev2020-12-171-2/+3
| | | | | | | | | | Use Q_OBJECT_BINDABLE_PROPERTY instead of non-existing ones Task-number: QTBUG-85520 Change-Id: I47e3ff150f54176b42a478fd3ff639754d90e70a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 50e1976437f645e9d6571d4498e9d44388e59c19) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Move QObjectBindableProperty documentation into snippet fileFabian Kosmale2020-12-171-18/+1
| | | | | | | | | | | | The \Q_OBJECT macro has been removed but using Q_OBJECT in the file would erroneously trigger automoc. Avoid the issue by moving the snippet into its own file. Task-number: QTBUG-89505 Change-Id: I6630ff4bfcbf33eae348ac3d92aae1878dc573ea Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 2c8d7411ace96f268d0692b366364d606f2608be) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Handle eager binding calling setBindingFabian Kosmale2020-12-092-0/+9
| | | | | | | | | | | | | | | | | | When an eager binding triggers a setBinding call, we end up with a special kind of binding loop: setBinding() -> evaluate -> notifyObserver ^ | | / ---------------------------- We now catch set condition, and set the binding status to BindingLoop (with a distinct description). Task-number: QTBUG-87153 Task-number: QTBUG-87733 Change-Id: I9f9915797d82eab820fc279baceaf89d7e5a3f4a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit ddc585b7c773786045f3658d7da5425ed2f2f786) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: Add missing QT_MANGLE_NAMESPACEMorten Johan Sørvig2020-12-082-2/+2
| | | | | | | | | | | | KeyValueObserver and RunLoopModeTracker were causing “Class is implemented in both...” messages when loading multiple namespaced Qt versions into the same process. Change-Id: Idbd2229c61cde6fba2c12b35d045390a371dee68 Fixes: QTBUG-89059 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit c2c163a7d8cb95a4901b742a72184975e791635a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QSystemSemaphorePrivate: Fix a call to tr() to translate()Tuomas Vaarala2020-12-081-1/+1
| | | | | | | | | | | Calling QCoreApplication::tr() without #if QT_CONFIG(translation) can cause the build to fail if configured without translation. Changing the call to QCoreApplication::translate() fixes that. Change-Id: I48f0e1be14fc81360b8268620afc2f6c8f255819 Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit 1051e23ce91a980c5e961b4dcb6d61997bc08050) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QPropertyAlias example, which did not compileAndreas Buhr2020-12-071-3/+3
| | | | | | | | | | The QPropertyAlias example did not compile and comments were out of sync with code. This patch fixes both. Change-Id: I5717f8df99f4936d0bcbae8df7d2d17e8086951d Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 0e96e1fb752e0b7c99927e77e7ac3244b2e0c118) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QProperty example so that comments match implementationAndreas Buhr2020-12-071-1/+1
| | | | | | | | | | The comments in the QProperty examples slightly mismatched the implementation. This patch fixes it. Change-Id: I03cfb35c024fad8ea4eaa5d5db220e1907f06bc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 3fbf922cc5925a13fbfadfe1f5fa8312209c097a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make the signal argument in Q_OBJECT_BINDABLE_PROPERTY optionalLars Knoll2020-12-072-2/+15
| | | | | | | | | | | | The intention was always that you can define properties that do not require a changed signal. But having to explicitly pass a nullptr as signal parameter into the macro is ugly, so use the cool QT_OVERLOADED_MACRO to make it optional. Change-Id: I0ce366d043850f983c968d73c544d89933c48df9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit cb39ea05810bc207100018589da658a0cce98edb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Improve the documentation for QElapsedTimer::restart, include unitsAleix Pol2020-12-051-1/+2
| | | | | | | | | | Specify that QElapsedTimer::restart returns milliseconds Change-Id: I47d9ffde7b0f73c30b14d2ce8467ec0a553b58f8 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 302254f90f41509b3d1111551296134cd76a3db5) Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QBindable: Disallow mutation if read-onlyFabian Kosmale2020-12-041-2/+2
| | | | | | | | | | | | | If a QBindable is created from a computed property, it is not possible to actually set a value or a binding. If we try to do it anyway, we'd get a crash. Thus we now check whether the function pointer is null before invoking it. Task-number: QTBUG-87153 Change-Id: I5bedb9080ccf79d9b8166b80d5733d095ed76f8d Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit e236faa75f446aa3378fb013cce6598c9e076ccb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-12-0410-20/+20
| | | | | | | | | | | | | | | 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. Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 0440614af0bb08e373d8e3e40f90b6412c043d14) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QTranslator::load() search order not following uiLanguages orderKarsten Heimrich2020-12-031-25/+9
| | | | | | | | | | | | | Merge the exact and and fuzzy search loop. This way we prioritize translations which match a more preferred language loosely over ones which match a less preferred language exactly. This is likely what most users want. Fixes: QTBUG-86179 Change-Id: Id1610c82a2e77edf9a5d4417968dcc4c307810d5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit 8df2bf04917e742470bbd1ff69e003811c5975ff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Avoid spurious dependencies by suspending binding stateFabian Kosmale2020-12-023-9/+36
| | | | | | | | | | | Avoid spurious bindings by resetting the binding state before calling the setter of eager properties. Fixes: QTBUG-88999 Change-Id: I1e3b5662307d906598335a21d306be9c606529d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit b21dba98e3e557eece0497aeea0f0beb70cc62da) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add a note about where to declare the streaming operatorsLars Knoll2020-12-011-1/+2
| | | | | | | | | | | | | Streaming operators for types used together with QMetaType should get declared in the same namespace as the type itself because of C++s ADL rules. Add a note about that to the documentation. Fixes: QTBUG-88990 Change-Id: I5d687576c6d926823dd0f1fec0743e877ae271af Reviewed-by: Robert Griebl <robert.griebl@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 5494f0af323a42390f9375c75e9298290ecb7662) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix documentation of QMetaType::TypeFlagAndreas Buhr2020-12-011-1/+1
| | | | | | | | | | | | QMetaType::TypeFlag::IsQmlListType was renamed to QMetaType::TypeFlag::IsQmlList . This change was not reflected in the documentation. This patch adapts the documentation to this change. Task-number: QTBUG-88533 Change-Id: I70be218f5f72b42aacb15ecd46972d5c808d86de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit bb3a53d917a5bc5681df893c8af32db477f41f94) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix various documentation warningsTopi Reinio2020-11-301-1/+1
| | | | | | | | | | | | | | - QList iterators are now nested classes inside QList. - Drop reference to Qt OpenGL Widgets landing page, there is no such page. - Fix typos and linking issues. Fixes: QTBUG-86295 Change-Id: I964843deb81aa55ff8ddb9a1c2b004cb72e68de9 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 99abdd180bd6f626f4ca94806fdaddbeb3774325) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Simplify the safeguarding logic in notify()Lars Knoll2020-11-263-118/+80
| | | | | | | | | | | | | | | | | The logic in notify() was doing quite a bit more work than it needed to. By inserting a dummy node after the current one instead of replacing it, we can avoid half of the data shuffling that has been happening and also don't need a back pointer when executing the notification. Also avoid calling a semi expensive destructor of QPropertyObserver. Reduces the overhead of notify() by ~30%. Pick-to: dev 6.0.0 Change-Id: I7ce16bcf9cd9c4368c18bf875fc959223452fd4f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Inline the fast path for removeBinding()Lars Knoll2020-11-262-10/+17
| | | | | | | | | | Save a function call in the common case where we don't have a binding This makes a rather large performance difference for setters that do not have a binding. Pick-to: 6.0.0 dev Change-Id: I140f29790f6fe868721a33b9fad37205e547b8e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Smaller cleanup in QBindingStorageLars Knoll2020-11-261-11/+11
| | | | | | | | Unify code paths and avoid excessive code generation. Pick-to: 6.0.0 dev Change-Id: I4a54234dd322bba380cc45d4f9c97d97a0c93303 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Inline the fast path of a few methodsLars Knoll2020-11-263-18/+37
| | | | | | | | | No need to do function calls for the case where we return immediately after checking a boolean. Pick-to: dev 6.0.0 Change-Id: I3e449850a10fcf82acb843cce6da6dfd98de32ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove ExtraBit and FlagMask from QPropertyBindingDataLars Knoll2020-11-263-22/+11
| | | | | | | | | They are not needed and removing it can simplify the code in some places and avoid a couple of masking operations. Pick-to: dev 6.0.0 Change-Id: I0e4241a2784026aa89deed35f408b094e89a11a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Inline the QPropertyBindingPrivatePtr destructorLars Knoll2020-11-262-4/+8
| | | | | | | | | In many cases, it only derefs and does nothing else. Inline the fast code path. Pick-to: dev 6.0.0 Change-Id: Ib605c385c1683f7833f7189c84d6cf4eb5b0e59e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize code in QTaggedPointerLars Knoll2020-11-261-1/+1
| | | | | | | | | | | | | | Don't execute instructions that will never do anything. Directly add the tag to the pointer in the constructor to avoid additional masking operations, and avoid a masking op that is in practice a no-op in setTag(). Do the same optimization in QTagPreservingPointerToPointer. Pick-to: dev Change-Id: Ia364f89cbe6ccc876ec9bda0c239fc4f57c10501 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Inline access to the QBindingStorageLars Knoll2020-11-267-40/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | And inline the fast checks inside the methods in QBindingStorage. This allows QObjectBindableProperty and friends to inline all the fast checks and almost completely eliminates the overhead for property accesses when no bindings are being used. Read and write times of QObject based properties when no bindings are being used: Read Write Old style property: 3.8ns 7.3ns QObjectBindableProperty (no notification): 4.5ns 4.3ns QObjectBindableProperty (with signal): 4.5ns 7.6ns QObjectBindableProperty (inline accessors): 3.2ns 3.4ns Numbers without this patch: Old style property: 3.8ns 7.9ns QObjectBindableProperty (no notification): 7.2ns 7.7ns QObjectBindableProperty (with signal): 7.2ns 16.0ns QObjectBindableProperty (inline accessors): 6.3ns 6.7ns Pick-to: dev 6.0.0 Change-Id: Ifd1fa3a489c3be8b1468c0b88af547aac397f412 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QVariant/QMetaType::compare APIsGiuseppe D'Angelo2020-11-254-26/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::optional<int> is the wrong datatype to use for compare. First and foremost, it can't be used in the idiomatic form of auto r = a.compare(b); if (r < 0) ~~~ // a is less than b if (r > 0) ~~~ // a is greater than b which we *already* feature in Qt (QString, QByteArray). Also, std::optional<int> (explicitly) converts to bool, which is a trap, because the result of the comparison can be accidentally tested as a bool: if (a.compare(b)) ~~~ // oops! does NOT mean a<b Not to mention extending this to algorithms: auto lessThan = [](QVariant a, QVariant b) { return a.compare(b); }; // oops! std::ranges::sort(vectorOfVariants, lessThan); which thankfully doesn't compile as is -- std::optional has an *explicit* operator bool, and the Compare concept requires an implicit conversion. However, the error the user is going to face will be "cannot convert to bool because the operator is explicit", which is deceiving because the fix is NOT supposed to be: auto lessThan = [](QVariant a, QVariant b) { return (bool)a.compare(b); }; // big oops! Instead: backport to Qt the required subset of C++20's <compare> API, and use that. This commits just adds the necessary parts for compare() (i.e. partial ordering), the rest of <compare> (classes, functions, conversions) can be added to 6.1. Change-Id: I2b5522da47854da39f79993e1207fad033786f00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3e59c97c3453926fc66479d9ceca03901df55f90) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Return subclass type from overrides of QEvent::cloneVolker Hilsheimer2020-11-241-4/+4
| | | | | | | | | | | C++ allows overrides to return a covariant type, so if calling code has already cast the callee down to the right type, don't require it to cast the returned clone down as well. Change-Id: I802f00a3c78e03047046986d0ed0a479b47573b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 146b37cdf376fb2fde85fa27326acfbeb2a024e3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMetaType: Track whether type is QML list typeFabian Kosmale2020-11-232-0/+6
| | | | | | | | | | This information is required in the QML engine to handle list properties (instances of QQmlListproperty<T> and list<T> types from QML). Change-Id: I1e30572f1c91f58b290cb9b4b07433af99a1db6f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 5806ecf5cb24cf39ea2608d42246eafbaa817582) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Delete move constructor and move-assignment for QEventVolker Hilsheimer2020-11-211-1/+3
| | | | | | | | | | | As of 19f9b0d5f54379151eb71e98555b203ad6756276 we define a protected copy constructor and assignment operator. Static analyzers warn about missing move variants, so delete those in addition. Change-Id: I28c1a2afd4560ce35a258bde507dafd93245b75b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 291e8e729ee7a28e579c3aea22fd4482cd271ed7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make QMetaTypeInterface constexpr on WindowsLars Knoll2020-11-191-44/+40
| | | | | | | | | | | | | | | | This was so far problematic as it gave various link errors. The solution to that seems to be to make the default constructor of QPairVariantInterfaceImpl constexpr to get around one set of problems. The other problem to solve where undefined references to metaobjects. The reason for that is apparently that QMetaTypeInterface contains a direct pointer to the meta object, something the linker doesn't like. Adding a level of indirection by using a function that returns the pointer seems to solve that problem. Fixes: QTBUG-88468 Change-Id: I5612ae807ea3b7e49bc40349d8d1fca1be9bd7ee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Disable copying and assigning of QEventVolker Hilsheimer2020-11-192-4/+12
| | | | | | | | | | | | | | Polymorphic classes should not be copied. However, we do rely on event copying in our propagation logic. So, make the members protected, don't delete them, using a dedicated macro. This way, QMutable*Event classes can be used to make copies. Remove some last usage of copying of QInputMethod(Query)Events. Change-Id: Ia0a8ae4ca9de97dcd7788ca3c6ed930b6460c43a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Allow cloning of event objectsVolker Hilsheimer2020-11-172-0/+15
| | | | | | | | | | | | We have use cases for cloning of events, e.g. in the state machine and for event propagation. Provide the means to do so through a virtual method. Adapt QFutureCallOutEvent::clone, which is now an override. No code seems to be using that method. Change-Id: I6864d6597f6de800343c4dc458a7994e84dc6fb4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-163-3/+3
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Drop the d-pointer of QEventVolker Hilsheimer2020-11-122-7/+4
| | | | | | | | | | | | | It's not been used ever since it was added in the Qt 2 days, other than a hack in QGraphicsView that could be solved more elegantly. With this change, QEvent is only 16 bytes large, which is nicely aligned with C++'s default operator new alignment, and we still have plenty of bits (plus an unused bool) left for extensions. Change-Id: If9376d90b92983db7fc12575f3893064a1797adf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Clean up and pack data members of QEvent classesVolker Hilsheimer2020-11-122-38/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure all bits reported by sizeof for the most important public event classes are used optimally. QEvent is 24bytes large due to default alignment in C++, so we might just as well use bool instead of bitfields for the most important data members. This generates less (and thus smaller and faster) code, and we still have plenty of bits available for future needs. Default the copy constructor and assignment operator, the assert and tracing seem to be relics from the Qt 3/4 days. Note: QEvent's d-pointer is currently unused, with the exception of a hack in QGraphicsView. Removing that would save another 8 bytes through the entire event hierarchy. For the new classes in the QInputEvent hierarchy, apply the same principle. Allocate bits in QInputEvent and QSinglePointEvent to fill the 8-byte aligned space. Using some of those bits for QMouseEvent and QWheelEvent makes sure we don't increase the size for those in spite of additionally reserved bits. As a result of this, several QInputEvent and subclasses become 8 bytes smaller on clang and gcc (with the exception of QNativeGestureEvent) while at the same we have more space for future extensions. The sizeof's for the various classes on different compilers produce these before and after result: clang +/- gcc +/- msvc +/- QEvent 24 0 24 0 24 0 QInputEvent 56 -8 56 -8 48 0 QPointerEvent 80 -8 80 -8 72 0 QSinglePointEvent 96 -8 96 -8 88 0 QMouseEvent 96 -8 96 -8 88 0 QTabletEvent 112 -8 112 -8 96 -16 QKeyEvent 104 -8 104 -8 96 0 QNativeGestureEvent 120 0 120 0 120 0 QWheelEvent 112 -8 112 -8 112 -8 So, with this change we save 8 bytes on gcc and clang for many event types, esp on Linux systems. As a drive-by: replace ulong with quint64, make QTabletEvent data floating point, and rename some variables for clarity. Change-Id: I4cf81c8283262cbf59ee3fb7064a59837332ced7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Purge QCoreApplicationPrivate::cloneEvent and overridesVolker Hilsheimer2020-11-122-20/+0
| | | | | | | | Not used anywhere in Qt 6, and if whatever needs this ever comes back, then we won't implement it like this. Change-Id: I99655ba5825644cef3686bbe50ca688b68f5c2a4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Add missing brief statements for \property documentationTopi Reinio2020-11-121-1/+1
| | | | | | | | ... where applicable. Fixes: QTBUG-88232 Change-Id: I835df434765caededd35d5114965b4a1663e7942 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix QGraphicsView's abuse of QEvent's d-pointer in Leave event handlingVolker Hilsheimer2020-11-112-0/+2
| | | | | | | | | | | | | | QGraphicsSceneEvent carries a widget pointer, and we can add a new event type. Assert that QGraphicsScene doesn't get Leave events from elsewhere. This was the only "usage" of QEvent's d-pointer in Qt, so with this gone we can reduce the size of QEvent by 8 bytes. Change-Id: I0513daf742de9084d0469d55b7a7f41b667e8081 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename remaining QEvent variables to m_ convention; init m_reservedShawn Rutledge2020-11-105-23/+25
| | | | | Change-Id: I08694657b7c9d2713d0cb33519698dbba3bfdffa Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>