summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-216-10/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtCore: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-01-204-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by providing a hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. Don't document it, otherwise we'd be unable to pick it to 6.2. Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build: before: **** Template sets that took longest to instantiate: [...] 27766 ms: qSwap<$> (9073 times, avg 3 ms) [...] 2806 ms: std::swap<$> (1229 times, avg 2 ms) (30572ms) after: **** Template sets that took longest to instantiate: [...] 5047 ms: qSwap<$> (641 times, avg 7 ms) [...] 3371 ms: std::swap<$> (1376 times, avg 2 ms) [qt_ptr_swap<$> does not appear in the top 400, so < 905ms] (< 9323ms) As a drive-by, remove superfluous inline keywords and template ornaments. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Win32: always allow the event loop to be woken up by posted eventsVolker Hilsheimer2022-01-191-0/+2
| | | | | | | | | | | | | | | | | | | We set the wakeUps atomic to prevent multiple WM_QT_SENDPOSTEDEVENTS from being posted. However, this might happen right after the event processing thread cleared the atomic, but before it processed the previous WM_QT_SENDPOSTEDEVENTS message. In that case, we end up with a set atomic and an empty event queue, resulting in the event loop to block even though there are posted QEvents. To prevent that, always reset the atomic when we handle the WM_QT_SENDPOSTEDEVENTS message. In that case, we either call sendPostedEvents, or startPostedEventsTimer. The former already resets wakeUps; reset it in the latter as well. Fixes: QTBUG-99323 Pick-to: 6.2 6.3 5.15 Change-Id: I931c02be9c42b02e8ca20daba5059cd8185f0a37 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* QPropertyBindingPrivate: move static_assert()s to .cpp fileMarc Mutz2022-01-192-2/+6
| | | | | | | | | | | | | | | | | | One of them has managed to percolate up to the top of the Clang -ftime-trace list of expensive template instantiations when building libQt6Gui.so with -pch: **** Templates that took longest to instantiate: 7882 ms: std::is_trivially_destructible<QPropertyBindingSourceLocation> (135 times, avg 58 ms) The checks aren't really necessary, because the compiler would complain about the union's deleted dtor if any of the members were not trivially destructible. Keep it around, though, but in the .cpp file. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I74a513a907735bde298e0bd9557d10abbcee5c91 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove (set but) unused member from QTimerPrivateEdward Welbourne2022-01-181-3/+1
| | | | | Change-Id: I004fef8ce84cdc74837f674239c05901000bee33 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMetaType: add a missing check for null d_ptrThiago Macieira2022-01-181-1/+1
| | | | | | | | | | | | | Bug introduced in 6.0. This is the only unprotected d_ptr I could find. [ChangeLog][QtCore][QMetaType] Fixed a bug that would cause QMetaType::compare() and QVariant::compare() to crash on invalid meta types and variants. Pick-to: 6.2 6.3 Fixes: QTBUG-99960 Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1f7b2d146688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Use \inmodule for all classes and headersTopi Reinio2022-01-172-1/+2
| | | | | | | | | | | | | | | QDoc made some assumptions about the module a class/header belongs to, based on the source file path. This feature is rather error-prone and unnecessarily complex and will be removed from QDoc. Define modules explicitly to avoid documentation warnings when this removal happens. Pick-to: 6.2 6.3 Change-Id: I7947d197db5ac36c12e816caa19bb2f74eda8849 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* qmetatype: Fix incorrect more than one typedef warningJonas Kvinge2022-01-171-1/+1
| | | | | | | | | | | | | | The names are the keys of a hash so they can come in any order. That means the loop above, which stops before the end if it finds a name that is not the official one, may not have seen the official yet. If it has reached the end, then there is no typedef alias. Fixes: QTBUG-99620 Pick-to: 6.2 6.3 Change-Id: I3bd638766c494b32c665190d01db15c4cbc587b5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Prevent repeated instantiations of ↵Marc Mutz2022-01-151-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qRegisterNormalizedMetaType<QList<QModelIndex>>() This, finally, shows some expected results: Clang -ftime-trace: $ ClangBuildAnalyzer --analyze qtgui-spec-before.trace | head -n6 Analyzing build trace from 'qtgui-spec-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 665.7 s Codegen & opts (backend): 298.9 s $ ClangBuildAnalyzer --analyze qtgui-spec-after.trace | head -n6 Analyzing build trace from 'qtgui-spec-after.trace'... **** Time summary: Compilation (525 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 301.0 s GCC 11 time (bash builtin): $ time for ((i=0; i < 3; ++i)) do touch ../qt5/qtbase/src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so real 4m10,918s user 49m10,099s sys 3m11,719s $ git revert --no-commit HEAD $ time for ((i=0; i < 3; ++i)) do touch ../qt5/qtbase/src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so [268/268] Creating library symlink qtbase/lib/libQt6Gui.so.6 qtbase/lib/libQt6Gui.so real 4m18,630s user 51m11,491s sys 3m16,479s The technique in the comment in qmetatype.h doesn't work on Clang - it runs into -Winstantiation-after-specialization. The whole extern template stuff so miserably fails to meet the goals set out in N1448, not only for MSVC and class templates, but, it seems, on all compilers, and for function templates, too, that I'm giving up on it for now. Unfortunately, I'm not really seeing a way to hide this stuff behind a macro, yet. Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: I500fd04555e0bd76ac021f75582bd8d8cf339378 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Allow reading QObject::objectName from other threads againAllan Sandfeld Jensen2022-01-131-0/+4
| | | | | | | | | | | | The new binding system made it impossible to read from non-owning threads, but we have code that did so with external locking. This patch makes it safe again, assuming all reads and writes are locked. This is left intentionally undocumented. Pick-to: 6.3 6.2 Task-number: QTBUG-99775 Change-Id: I845afa5d545ca0ac762ac369181b1497dac52195 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Revise the explanation for leaving QTest::qWait() as it isEdward Welbourne2022-01-131-4/+6
| | | | | | | | | | | | | The recently aborted attempt to act on the comment's recommendation revealed a major performance regression, so mention that instead of the now historical compiler problem that used to be our reason for not simply calling qWaitFor(). Change-Id: I81714b556998217a833c21b4208118b7292b7a96 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QMetaType: Allow conversion of derived gadget types to their base typesUlf Hermann2022-01-131-5/+11
| | | | | | | | A derived gadget has an is-a relationship with its base type. It should be convertible. In fact, canConvert() already tells us it is. Change-Id: I71a5ac9afd78e88adb23b4d0e757f34077f63207 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add a few explicit conversions back from intThiago Macieira2022-01-121-1/+1
| | | | | | | | | | Suppresses GCC's -Wconversion, which is not enabled by default. error: conversion from ‘int’ to ‘quint8’ {aka ‘unsigned char’} may change value [-Werror=conversion] Change-Id: I0e5f6bec596a4a78bd3bfffd16c998102bd51f7c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QVariant: fix incorrect warning about duplicated alias where there isn'tThiago Macieira2022-01-121-0/+1
| | | | | | | | | | | | | | We were always matching a type name to itself because we forgot to advance the iterator after we did match. The issue was introduced in commit 46dc8e453ae1d0c1eb749cfebe686995f3a6cfd0. Fixes: QTBUG-99620 Task-number: QTBUG-96916 Pick-to: 6.3 6.2 Change-Id: Ib42b3adc93bf4d43bd55fffd16c8a5df6306e404 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Jonas Kvinge <jonas@jkvinge.net>
* Add Q_FLAG for QEventLoop::ProcessEventsFlagsTor Arne Vestbø2022-01-121-0/+1
| | | | | | | | | Helps debugging when printing the flags. Pick-to: 6.3 6.2 Change-Id: Icb306bb1efaf9d3c645c2ac86796d95da5afc4a3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "Implement QTest::qWait() in terms of QTest::qWaitFor()"Michal Klocek2022-01-081-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5c908c826313143a65ef7e95e5af6625fe1ba813. git-bisect points to this commit as the cause for serious test regressions in the qtwebengine module where test time execution goes up 10 times (at least for debug builds), causing timeouts. The reason for the time regression in test execution is caused as the 'processEvents' call is no longer executed with 'remaining' time: QCoreApplication::processEvents(QEventLoop::AllEvents, remaining) 'processEvents' do not spin for the whole duration and instead it calls 'predicate' after all event processing but before proceeding with new events. This introduces significant Chromium's message pump lag and makes test execution much slower. In case of relanding this change we need to go through all tests and extend timeouts, which is not feasible at the moment. This is a quick-fix for 6.3. Change-Id: I90696479bfb9f0a0b8a8acc5bb7e7058b7d0c462 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f2d0b327e4e6a6c4b72998c290d554d6c4a8f5b6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix qobject_cast on partially destroyed QWidget/QWindowGiuseppe D'Angelo2022-01-052-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QWidget and QWindow use bits in QObjectPrivate to provide for a couple of shortcuts -- one in qobject_cast, and another in the isWidgetType() / isWindowType() functions in QObject. These can be optimized by simply looking at the bits, without actually doing more expensive runtime casts. These bits were set on construction, but not unset on destruction. The result was for instance that destroying a QWidget would report that the object was still a QWidget when ~QObject was reached. Fix this 1) by setting the bits only when QWidget / QWindow constructors start; 2) by resetting the bits once ~QWidget / ~QWindow are completed. Technically speaking this is not 100% correct in the presence of data members, but luckily those classes don't have any. Amend an existing test for QWidget (whose comment said exactly the opposite of what the test actually did) and add a test for QWindow. Some other code was wrongly relying on isWidgetType() returning true for destroyed QWidgets; amend it as needed. [ChangeLog][QtCore][QObject] Using qobject_cast on partially constructed or destroyed QWidget/QWindow instances now yields correct results. Similarly, using the convenience isWidgetType() / isWindowType() functions now correctly return false on such instances. Before, qobject_cast (and the convenience functions) would erroneously report that a given object was a QWidget (resp. QWindow) even during that object's construction (before QObject's constructor had completed) or destruction (after QWidget's (resp. QWindow's) destructors had been completed). This was semantically wrong and inconsistent with other ways of gathering runtime type information regarding such an object (e.g. dynamic_cast, obj->metaObject()->className() and so on). Pick-to: 6.3 Change-Id: Ic45a887951755a9d1a3b838590f1e9f2c4ae6e92 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* [doc] QCoreApplication::installTranslator() doesn't take ownershipMarc Mutz2022-01-031-0/+2
| | | | | | | | Document it. Pick-to: 6.3 6.2 5.15 Change-Id: I25d305945bf29348d6ea5756fbf80c418f812d0f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* wasm: hardcode idealThreadCount for some browsersLorn Potter2021-12-241-1/+5
| | | | | | | | | Browsers like Safari do not support the hardwareConcurrency property. Will hard code it to 2, as iOS only supports that amount. Pick-to: 6.3 6.2 Change-Id: Icb35d3b698b28d8191a554167dc8cc262b806fb2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: add virtual processWindowSystemEvents()Morten Johan Sørvig2021-12-232-0/+9
| | | | | | | | | | The QtCore event dispatcher will be used from QtGui as well. Add virtual function where window system events processing can be added. Pick-to: 6.3 Change-Id: Ia6eda9ae18b2e91189ef9f60b6621d19a83313de Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Add QObject::isQuickItemType() for convenienceYuhang Zhao2021-12-232-1/+15
| | | | | Change-Id: Ibde4e919ba028117336974eb7a804aa11c1ee086 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QVariant: use a typedef name when saving user types to QDataStreamThiago Macieira2021-12-173-6/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the way Qt 5 and 6 registered type names, they end up producing different type names for the same content for a typedef. For example, because Q_DECLARE_METATYPE can't manage a comma (it's a macro), users are forced to write something like: using MyTypeMap = QMap<QString, MyType> Q_DECLARE_METATYPE(MyTypeMap) Qt 5's Q_DECLARE_METATYPE's argument "MyTypeMap" was the only name we knew about the type, so that's what got saved in the stream. However, Qt 6 QtPrivate::typenameHelper is much more clever and obtains the name from the compiler itself, so it "sees through" the typedef and registers "QMap<QString,MyType>" as the official type name. If another library/plugin has a different typedef name for the same type (e.g., StringTypeMap), it's indeterminate which type gets saved and will even change from run to run (depends on the QHash order). [ChangeLog][QtCore][QDataStream] If QDataStream is used with a QDataStream::Version < Qt_6_0 to serialize a user type that was registered via a typedef with the metatype system, the typedef's name is used in the stream instead of the non-typedef name. This restores compatibility with Qt 5, allowing existing content to read the same QDataStreams; reading from older Qt 6 versions should not be affected. (Note: if more than one typedef name is registered, it's indetermine which name gets used) Fixes: QTBUG-96916 Pick-to: 6.3 6.2 Change-Id: I2bbf422288924c198645fffd16a8d811aa58201e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Q_{APPLICATION,GLOBAL}_STATIC: use variadic macrosThiago Macieira2021-12-172-48/+18
| | | | | | | | | | | | | | | | | We can't remove Q_GLOBAL_STATIC_WITH_ARGS, for compatibility reasons. It's also the only way to pass uniform initialization (i.e., initialize the value as value{with_braces}), though I don't think this is used almost anywhere due to the fact that you couldn't pass more than one argument. But Q_APPLICATION_STATIC is new in 6.3, so we have time to change it. [ChangeLog][QtCore][QGlobalStatic] The Q_GLOBAL_STATIC macro is now variadic. Any extra arguments are used as constructor arguments, obliterating the need to use Q_GLOBAL_STATIC_WITH_ARGS(). Pick-to: 6.3 Change-Id: Ib42b3adc93bf4d43bd55fffd16be3656a512fe53 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix INTEGRITY runtime qobject issueTatiana Borisova2021-12-161-1/+1
| | | | | | | | | | | | | | | | - There is no space symbol in the expression evaluation by GHS compiler. Because of space in prefix constant, begin pointer is moved too far and skips 1 letter in the class name. In result, on testing stage we see: I/O: FAIL! : tst_QObject::property() Compared strings are not the same I/O: Actual (property.typeName()) : ropertyObject::Alpha I/O: Expected ("PropertyObject::Alpha"): PropertyObject::Alpha Pick-to: 6.2 6.3 Change-Id: I52759860fd26b8d50df96dcc4ab0a6b005329a9f Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: implement socket notifier supportMorten Johan Sørvig2021-12-152-4/+145
| | | | | | | | | | | | Implement socket notifier support using Emscripten’s socket callbacks. This is sufficient for supporting non-blocking (tunneled) TCP and UDP sockets on the main thread. Change-Id: Ib9ee2698d029fb94d954c6872f8e118b0aa15499 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Rewrite Q_{GLOBAL,APPLICATION}_STATIC with C++17 goodiesThiago Macieira2021-12-122-46/+102
| | | | | | | | | | | | Especially static inline variables. This greatly reduces the amount of code that existed in macros, moving them to templates. Additionally, this removes one level of indirection from Q_APPLICATION_STATIC by removing the std::unique_ptr. We now directly manage the object's storage. Change-Id: I2cffe62afda945079b63fffd16bcc825cc04334e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Implement QTest::qWait() in terms of QTest::qWaitFor()Edward Welbourne2021-12-091-18/+2
| | | | | | | | A comment in the existing implementation encouraged doing so, but for a bug in GCC 6. We no longer care. Change-Id: Ia8cb2bc5e184510e3d756e8bbfe6bc0e852e6830 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a const overload for QMetaType::iface()Ulf Hermann2021-12-061-0/+4
| | | | | | | Change-Id: I865dc51d466d90636e177556d95558ba66f466de Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaType: port the BC fix for id() to new QT_REMOVED_SINCEMarc Mutz2021-12-062-15/+2
| | | | | | | The allows qmetatype.cpp compilation to enjoy PCH again. Change-Id: I47c5af33a5dbc930ee4c120b254e732c52bc2369 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QObject: Q_ASSERT the object type before calling a PMFThiago Macieira2021-11-272-5/+36
| | | | | | | | | | | | | | | | | | | | | | | | The old-syle signal-slot syntax had the advantage of not delivering signals to slots in derived classes after that derived class's destructor had finished running (because we called via the virtual qt_metacall). The new syntax made no checks, so a conversion from the old to the new syntax may introduce crashes or other data corruptions at runtime if the destructor had completed. This commit introduces a Q_ASSERT to print the class name that the object is not any more. Since this is in inline code, this should get enabled for users' debug modes and does not therefore depend on Qt being built in debug mode. It required some Private classes to be adapted to the new form, by exposing the public q_func() in the public: part. Pick-to: 6.2 Fixes: QTBUG-33908 Change-Id: Iccb47e5527544b6fbd75fffd16b874cdc08c1f3e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Long live Q_GADGET_EXPORT!Marc Mutz2021-11-272-7/+37
| | | | | | | | | | | | | | | | | | | | | | Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET allows passing an export macro. This is useful to avoid exporting the whole class just to get the staticMetaObject hidden therein exported. Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject subclasses, being polymorphic, always need to have a class-level export macro (to export their vtable), but while that technique also works for value classes (the Q_GADGET audience), it is not desirable for them, because it makes inline functions exported in Windows debug builds, which is not what we want, because it needlessly restricts what you can to with the inline functions (e.g. remove). [ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT for Q_NAMESPACE). Fixes: QTBUG-55458 Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QObject: don't #include qproperty.hMarc Mutz2021-11-231-2/+2
| | | | | | | | | | | | | | | | | | | | | The qobject.h header needs QBindingStorage in-size and QBindable in-name-only. The former was moved to its own header in a previous commit, which we include now, while the latter can just be forward-declared. This allows dropping the qproperty.h include from qobject.h. [ChangeLog][Potentially Source-Incompatible Changes] The qobject.h header no longer implicitly includes qproperty.h. If your code depends on the transitive include, explicitly include <QProperty> where needed. Task-number: QTBUG-97601 Pick-to: 6.2 Change-Id: I8d6320f5978e20dfc394d2b1e49f626b99529c37 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qapplicationstatic.h: fix syncqt warningMarc Mutz2021-11-231-1/+1
| | | | | | | | | | Warning was: "QtCore: WARNING: src/corelib/kernel/qapplicationstatic.h includes QMutex when it should include QtCore/QMutex" Comply. Change-Id: Ifc74b4f8052b7e95f86cab9a01a7e91bcbc3022d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove unneeded int conversions in qmetatype.hKai Köhne2021-11-191-9/+9
| | | | | | | | | | | | | | | They were added in Qt 5, where QByteArray::reserve() was an int argument, and qstrlen() was returning an int. In Qt 6, both accept and return qsizetype/size_t. As a side effect, this fixes various informational messages when loading a Qt project into Visual Studio 2022: lnt-arithmetic-overflow: A sub-expression may overflow before being assigned to a wider type. Pick-to: 6.2 Change-Id: Ifc9a1f7046a78bcfb97fe241d697c1bf91c6ba4f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce Q_APPLICATION_STATICMike Achtelik2021-11-182-0/+200
| | | | | | | | | | | | | | QObjects must be deleted if the QCoreApplication is being destroyed. This was previously done by implementing custom code in qtbase and other modules. So unify it and introduce a Q_APPLICATION_STATIC, based on the Q_GLOBAL_STATIC, which centralises the logic. Since we still have a few remaining living QObjects, this comes in handy to fix those as well. Task-number: QTBUG-84234 Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: check if objectClass() is not null in registerNativeMethods()Assam Boudjelthia2021-11-151-3/+4
| | | | | | | | | | | | In case the class doens't have a default constructor, checking for object.isValid() will give false because the object won't be created, however, the class could still be loaded and we could have a valid jclass. Pick-to: 6.2 Fixes: QTBUG-96069 Change-Id: I8d59e26d9d7c0e8e363ce443937091a374a24473 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* wasm: fix native timer update for the no-timer caseMorten Johan Sørvig2021-11-111-2/+10
| | | | | | | | | | | | | QTimerInfoList::timerWait() does not update the timespec out argument if there are no active timers, which caused the current code to calculate an arbitrary toWaitDuration. Instead use the timerWait() return value, and clear any native timers if there are no active Qt timers. Pick-to: 6.2 Change-Id: I7d5ec4c2930000bece6f6ea6c63e76f4df543b04 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: make timers work for the new event dispatcherMorten Johan Sørvig2021-11-111-3/+0
| | | | | | | | | | Don’t exit from the timer callback if there is no main thread event dispatcher, since it could be that the main thread event dispatcher is of the old event dispatcher type. Pick-to: 6.2 Change-Id: Ibb7a34a99e2001b52d2a985022f5baa7cd2152bf Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* qmetatype.cpp: provide missing initializer for const variableThiago Macieira2021-11-101-1/+1
| | | | | | | | qmetatype.cpp(1565): warning #854: const variable "metatypeHelper" requires an initializer -- class "struct <unnamed>" has no user-provided default constructor Change-Id: I2bbf422288924c198645fffd16a9b868ff7adcb9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Don't quit application if we're not in execTor Arne Vestbø2021-11-081-0/+3
| | | | | | | | | | | | | | | | The documentation states that the function will not have any effect before control enters the main event loop. Prior to 0c02f133f3daee1 this was incidentally true due to QCoreApplication::exit just setting quitNow to true and exiting all the event loops (which before exec were none), and exec() setting quitNow to false explicitly. But now that we plumb the quit down to the platform we can't rely on this incidental behavior, and need to check explicitly. Fixes: QTBUG-98088 Pick-to: 6.2 Change-Id: I54cece3630e39e4456abc3b372839c0b5c4c4713 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QCoreApplication: document the app's bindir is in libraryPaths()Thiago Macieira2021-11-051-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() function has been there since at least Qt 4.5.1, so the documentation for appendLibraryPaths() hasn't matched behavior for a minimum of 13 years. The documentation for libraryPaths() has mentioned this fact, though. Searching the application's bin dir is normal on Windows, as many application packages are a flat install with the .exe and all .dlls in one dir. I find it questionable to do so on Unix, though: any and all applications expecting to be installed by a Linux distribution would not install plugins to /usr/bin, whereas on macOS bundles have their own organization anyway. But I'm not prepared to change the behavior without more justification. I can think only of broken configurations (such what is described in QTBUG-97950 where a combination of bad decisions led to scanning all of /usr/bin) and running an executable that is stored in a world-writable directory. Task-number: QTBUG-97950 Pick-to: 6.2 Change-Id: Ice04365c72984d07a64dfffd16b440868373d7a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Move Q_OBJECT_COMPUTED_PROPERTY to QObjectComputedPropertyLuca Di Sera2021-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | `Q_OBJECT_COMPUTED_PROPERTY` is a macro that is used to declare a `QObjectComputedProperty`. The documentation for the macro was related to the `QObjectCompatProperty` documentation, which is internal. A link to `Q_OBJECT_COMPUTED_PROPERTY` appears in `QObjectComputedProperty`'s page, but fails to resolve as the required documentation page is internal. Furthermore, `QObjectCompatProperty` has a macro that is equivalent to `Q_OBJECT_COMPUTED_PROPERTY`, `Q_OBJECT_COMPAT_PROPERTY`, whose documentation is declared related to `QObjectCompatProperty`. It is hence assumed that relating the documentation for `Q_OBJECT_COMPUTED_PROPERTY` to `QObjectCompatProperty` was a typo, such that the documentation for the macro is now moved to be related to `QObjectComputedProperty`, resolving the linking issue in the process. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2c1bfd6ba64f13e186c65701593047b64bf0c199 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Extract Header qbindingstorage.hMarc Mutz2021-11-042-62/+119
| | | | | | | | | | | | | | | QBindingStorage doesn't depend in-size on much else in qproperty.h, but is used in-size in qobject.h, thus requiring qobject.h to include qproperty.h. As a first step, move the class and the bits it actually depends on, to a separate header file, qbindingstorage.h, and, for now, just include that from qproperty.h. The end goal here is to make qobject.h independent of qproperty.h. Pick-to: 6.2 Change-Id: I44245a5e57473067e3106d1fd70bf2d744ce0a5f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* wasm: enable event dispatcher asyncify supportMorten Johan Sørvig2021-11-042-23/+9
| | | | | | | | | | | | | | | | | | | | | Misc. fixes, including: Fix a couple of typos in the JavaScript code. Also, macros- within-macros don’t work, (without resorting to preprocessor token pasting), so remove the debug output for now. Limit the exec() “simulateInfiniteLoop” workaround to top-level application exec() only. This way, asyncify can be used for nested QEventLoop::exec() calls. (Emscripten supports one level of suspend only, so we don’t want to use that for the top-level exec(), but instead use it for dialogs and such). Use the new QEventLoop::ProcessEventsFlag::ApplicationExec enum value to detect the exec() call type. Change-Id: Ic702bfc31faf2e9f84ac5d3ccf43d067c5c61bf0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Add QEventLoop::ProcessEventsFlag::ApplicationExecMorten Johan Sørvig2021-11-033-2/+4
| | | | | | | | | | | | | | The wasm event dispatcher needs to differentiate between top-level QCoreApplication::exec() and QEventLoop::exec() calls. Add the “ApplicationExec” enum value. The value is undocumented, like EventLoopExec and DialogExec. Change-Id: I2924daee39ef85a3ea7e766e317b3071b5d7f541 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add warning about QCoreApplication deferred deleteMichal Klocek2021-11-011-0/+4
| | | | | | | | | | | | | | | In some bug reports we got code which does deleteLater() on QCoreApplication, however this is not going to work as the user may expect. In cases where an application uses Qt WebEngine, this leads to weird looking crashes on exit as webenginecontext is not destroyed. Pick-to: 6.2 5.15 Change-Id: I4d284f30b0c7cad15ba6da3d65cdf813c36ee036 Reviewed-by: Michael Brüning <michael.bruning@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Inline QPropertyBindingDataPointerAndrei Golubev2021-11-012-11/+12
| | | | | | | | | | | | The only non-inline function of that class was observerCount() which would use two of the inline functions defined in the header file, so we can safely inline observerCount() and make the whole class contain only inline methods Consequently, inline class doesn't have to be exported in Windows Change-Id: I41d144d9a50420bbc0091992b36cc36ac2567704 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Avoid superfluous template instantiationsFabian Kosmale2021-10-292-11/+8
| | | | | | | | | | | | Apparently msvc still parses the template and generates code for it when it encounters an extern template declaration. Thus, instead of speeding up compilation, it gets slowed down significantly as the instantiation would happen in every compilation unit that (transitively) included qmetatype.h. Task-number: QTBUG-97601 Change-Id: Id5e934afb14ad8973df1b9197aef336b22220111 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Extend documentation for bindable propertiesIvan Solovev2021-10-291-4/+9
| | | | | | | | | | | | | Extend the general property system page with a section on how to use bindable properties. Add some cross-references to improve the user experience. Task-number: QTBUG-97656 Pick-to: 6.2 Change-Id: I2520cdc168e3a8a66ea387e4ab717f4e0f969424 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QObjectComputedProperty docs: move example to snippetIvan Solovev2021-10-261-36/+1
| | | | | | | | | | | This patch amends 89a4c8d40d2ee1b8794dd7fcf80d226c5c87ba6c. It moves the code sample into a separate snippet file, which allows us to use Q_OBJECT macro in it without complaints from moc. Task-number: QTBUG-97656 Pick-to: 6.2 Change-Id: I368d8dd8c00dbbebd8a6bf3788be796c8ca4bce8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>