summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove QObjectPrivate::isSender/senderList, no longer usedDavid Faure2024-03-141-2/+0
| | | | | | | | | Only QAccessibleWidget was using them, and this was changed some time ago. No point in keeping dead code. Change-Id: I14bc40e6d87df234987e82385ce13433c2b82744 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Timers: add Qt::TimerId enum classAhmad Samir2024-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Which will be used to represent timer IDs. Thanks to Marc for the idea to use "a strongly typed int". QTimer got a new id() method that returns Qt::TimerId (can't overload timerId()). Various classes in qtbase have a member named timerId(), but a new method is needed anyway in QTimer so id() it is (this is the reason QChronoTimer only has id() and no timerId()). Besides timer.timerId() has an extra "timer". This commit fixes the inconsistency between QObject using `0` timer id to indicate "failed to start", while QTimer::timerId() returned `-1` to indicate "timer is inactive". QTimer::id(), being a new method and all, now returns Qt::TimerId::Invalid, which has value `0`, so that the values match between the two classes. Extend the unittests to ensure QTimer::timerId()'s behavior is preserved. [ChangeLog][Core][QObject] Added Qt::TimerId enum class, that is used to represent timer IDs. Change-Id: I0e8564c1461884106d8a797cc980a669035d480a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add virtual QObjectPrivate::writeToDebugStreamVolker Hilsheimer2024-02-101-0/+4
| | | | | | | | | | | | | QObject by default writes class- and objectName to the debug stream, but QObject subclasses might want to write different, or additional information. Providing class-specific debug stream operators is not a good solution for this, as it doesn't respect runtime polymorphism. With a virtual helper in QObjectPrivate, class authors can add an override. Change-Id: I382126ae5a56391d0c7e5ccb58fbbafa6aab5c77 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove qDeleteInEventHandlerTor Arne Vestbø2023-12-141-2/+0
| | | | | | | | | | It's equivalent to delete these days, and has been for a long time, since 2011 in fact, when the last remnants of QT_JAMBI_BUILD were removed. Change-Id: I7703e41c04204844da4ee75fa251b361e0db4ead Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QObject: replace _q_reregisterTimers with a lambdaAhmad Samir2023-07-311-1/+0
| | | | | | | | | | | | | | | - Pass the QList by value, no heap allocation and no plain new/delete - A lambda means that there isn't runtime string-based lookup to find the member method in QObjectPrivate The code is only a couple of lines and used in a single place, so might as well move the code from _q_reregisterTimers to the local lambda. Modify tst_moc to account for the numer of methods in QObjectPrivate changing. The test had hardcoded numbers. Change-Id: I07906fc7138b8e601e4695f8d2de1b5fdd88449c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaCallEvent: add ctors and create() overloads taking SlotObjUniquePtrMarc Mutz2023-07-211-0/+24
| | | | | | | | | This makes it clear who is responsible for obtaining additional strong reference to the slot objects, because these functions no longer do. Pick-to: 6.6 6.5 Change-Id: I39187e3c441d8f82d50d907731f1cbdfb2a95b9d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaCallEvent::create: extract template-argument-independent codeMarc Mutz2023-07-191-12/+4
| | | | | | | | | | Extract Method create_impl() with all the stuff that doesn't depend on create()'s template arguments, which will reduce compile time and amount of generated code. Pick-to: 6.6 Change-Id: I9d8f59c168873ac3527b570ef6142079824061cf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QSlotObjectBase: add Deleter and typedef for a unique_ptr using itMarc Mutz2023-07-191-1/+1
| | | | | | | | | | Use it in QMetaCallEvent, to have some automatic test coverage. Other code that might benefit has undergone changes since 5.15, so will be ported one-by-one to avoid conflicts on cherry-picks. Pick-to: 6.6 6.5 Change-Id: I566bab1803e3675f75a9fdf294a4b0f047d21c11 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMetaCallEvent::create(): re-order operationsMarc Mutz2023-07-191-4/+5
| | | | | | | | | | | | | | | | | | | | ... so that everything that requires argv is done first. Also introduce a new variable, argc, for sizeof...(Args) + 1. This will allow us to apply Extract Method to the tail end, which now no longer depends on argv or Args. As a drive-by, port from std::array to C arrays so we can use automatic array size deduction: There's still no such thing as partial CTAD (certainly not in C++17), so if we wanted std::array to deduce the size, we'd also need to let it deduce the type; and we don't want to add an ugly cast to the nullptr). C arrays, OTOH, can deduce the size while fixing the type since K&R C. Pick-to: 6.6 Change-Id: I5a694d4f4d41974eb4b1075ff030bbef902ed492 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Div. private RAII/smart ptr classes: mark ctors [[nodiscard]]Marc Mutz2023-06-211-1/+3
| | | | | | | | | | | | | | | | The following private APIs are either RAII or smart pointer classes: - QAutoPointer - QBoolBlocker - QFdContainer QUIP-0019 says to mark RAII and smart pointer class ctors [[nodiscard]], so do that. Pick-to: 6.6 Task-number: QTBUG-104164 Change-Id: Ibc77e6603fadf18ea28428a49635f46a5680b777 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QMetaCallEvent::create: pass arguments by const refVolker Hilsheimer2023-06-111-2/+2
| | | | | | | | | | Amends 4d7ae8a74e70896a757f483865fe7095120fedc1. Pick-to: 6.6 Change-Id: Id4379324c2399f2360b3553d297f38dd793af21c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QSlotObjectBase: move the `which` parameter to the 4th positionThiago Macieira2023-05-111-0/+4
| | | | | | | | | | | | | | | | | | | This places the first through third parameters on the exact positions that they will be used to perform the operations in the switch, saving the compiler from generating a few instructions to move data around. All ABIs Qt supports that pass any function parameters in registers at all pass at least 4. We keep the return type as void (instead of returning bool, for the Compare case) so the compiler can apply tail-call optimizations for those two typical cases. PMF case: https://gcc.godbolt.org/z/9oP5boKfj Function case: https://gcc.godbolt.org/z/e9vEzd5dj Functor case: https://gcc.godbolt.org/z/s8Ejjra7P Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Long live QtPrivate::CompactStorage<>Marc Mutz2023-05-091-24/+4
| | | | | | | | | | | | | | | | | | | | This is a generalization of QPrivateSlotObject's FunctionStorage. Changes from the old API: - uses a more neutral API (s/func/object/) - preserves cv-qualifiers and value categories - preserves constexpr'ness - adds a disambiguation tag (e.g. for use in a compressed_pair). The main feature is that it transparently uses the empty base-class optimization to stow away empty classes without allocating separate bytes for them. To be used for the public QSlotObject and QGenericRunnable, at least, so finally pulled the trigger and made it a separate component. Change-Id: I9a13bbdd1dcf64aaf5fc7b2d40a60050d61800b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: simplify ImplFns of Q(Private)SlotObjectsMarc Mutz2023-05-051-3/+4
| | | | | | | | | | | Drag the cast out of each case to before the switch. DRYs the code. Pick-to: 6.5 Change-Id: I117cc5d38379a11e9852fba61794fa59dc24a30f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add helper template for metacall event creationVolker Hilsheimer2023-04-181-0/+20
| | | | | | | | | | Setting up the args and types arrays is cumbersome and error prone, and we do it at least twice in qtbase. Provide a central implementation as a variadic template function, and make it exception-safe with a unique_ptr (the destructor of QMetaCallEvent will destroy the cloned arguments). Change-Id: I5ff400467928446264eaedddb394691e9e23d22e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix UBSAN warningsAllan Sandfeld Jensen2023-03-171-0/+1
| | | | | | | | Convert tagged pointer to an encapsulated tagged pointer type, and clean up where it is used. Change-Id: I9cf5b8d1dfa345eebaa185e44d762d5008769480 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* moc: Allow anonymous propertiesUlf Hermann2023-03-161-0/+8
| | | | | | | | | | | | This is private for now. It's very handy to have anonymous properties for the QML model/delegate adaptors. There are models with only "singular" model data that doesn't have any sub-properties. Such model data should be available from the model object via an empty string as role. This way we can get rid of a lot of special casing. Task-number: QTBUG-104752 Change-Id: I229e355a7cab064ee1c9f89557bc0244a5d0c90a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make it possible to use QObjectPrivate::connect in private codeVolker Hilsheimer2023-03-101-1/+2
| | | | | | | | | | | | | | | | | | | | In most QObjectPrivate-subclasses, the Q_DECLARE_PUBLIC macro is used in the private segment of the class declaration. In that case, the q_ptr becomes a private member of the private class, and then the QObjectPrivate::connect function can no longer be used, as it needs to access the d_ptr. Fix this by declaring QObjectPrivate, and the static-assert-helper, as friends of the class using the Q_DECLARE_PUBLIC macro. Adapt the QObject test by moving the Q_DECLARE_PUBLIC macro into the private section of the test-private, and add a compile test. Pick-to: 6.5 6.5.0 Change-Id: Ifc04be3b305221e138b1e08bb3a3838d871f4fcb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove redundant qsharedpointer.h #includesAhmad Samir2023-01-311-1/+1
| | | | | | | In some cases added #include <QtCore/qshareddata.h>. Change-Id: Idc84c4ad6b0bd58e1a67af335dfcff67fdf80b2a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBindable: Make ordinary Q_PROPERTYs bindablePatrick Stewart2022-11-301-0/+3
| | | | | | | | | | | Implements an adaptor from the notification signal of a Q_PROPERTY to QBindable. The Q_PROPERTY does not need to be BINDABLE, but can still be bound or used in a binding. [ChangeLog][Core][Q_PROPERTY] Q_PROPERTYs without BINDABLE can be wrapped in QBindable to make them usable in bindings Change-Id: Id0ca5444b93a371ba8720a38f3607925d393d98a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't access QObjectPrivate::declarativeData unguardedVolker Hilsheimer2022-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | The QObjectPrivate::declarativeData member is stored in a union with currentChildBeingDeleted. The QObject destructor always sets the currentChildBeingDeleted member of the union. It also sets the isDeletingChildren bool, which is the only way to find out which union member we can safely access. While the QObject destructor is deleting children and isDeletingChildren is set, we must not access the declarativeData member of the union. Add a test case that initializes the function pointers for the declarative handlers and constructs a situation where an object emits a signal while it is destroying children. Fixes: QTBUG-105286 Pick-to: 6.4 6.3 6.3.2 6.2 5.15 Change-Id: Iea5ba2f7843b6926a8d157be166e6044d98d6c02 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qobject_p.h: remove unused qreadwritelock.h includeMarc Mutz2022-05-171-1/+0
| | | | | | | | | | | | | | | | | Only qcoreapplication_p.h uses a QReadWriteLock (tanslationMutex), so include it only there. This include has caused QAtomicPointer<QReadWriteLockPrivate> to percolate to the top-5 of template instantiation hogs when compiling QtWidgets, as reported by Clang -ftime-trace. This patch improves that, because qcoreapplication_p.h isn't part of the PCH and is much less frequently included into QtWidgets TUs (68 instead of 142 times). Pick-to: 6.3 6.2 Change-Id: I2518040d83a04e7cef0645d7f4bf641fb50f49ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QObjectPrivate: rename the internal disconnect() to removeConnection()Thiago Macieira2022-05-061-3/+2
| | | | | | | Matches its counterpart addConnection(). Change-Id: If2e0f4b2190341ebaa31fffd16e315916eaaca37 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QObjectPrivate: mark inline functions not meant to be used elsewhereThiago Macieira2022-05-061-3/+3
| | | | | | | | | | | | | | | | | | The `inline` keyword does not control inlining, as we all know (use Q_ALWAYS_INLINE to force inlining, if required). However, it does control the emission of the out-of-line copy of an inline function, if the compiler did inline it where it got used: with the keyword, no copy is required, which is our objective here. Furthermore, we compile with -fvisibility-inlines-hidden with GCC-compatible compilers (all but MSVC and Integrity's), which means those functions will never be in the ABI of QtCore: they'll either have been inlined with no out-of-line copy, or that out-of-line emission is hidden. Change-Id: If2e0f4b2190341ebaa31fffd16e31584561669f2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QObjectPrivate: deinline a bunch of stuff only used in QtCoreThiago Macieira2022-04-131-216/+5
| | | | | | | | | | All of this connection management code is used only in QtCore and mustn't be touched by other modules (not even qtdeclarative). So there's no reason for it to be around and slow down the compilation time of everything using QObjectPrivate. Change-Id: If2e0f4b2190341ebaa31fffd16e31313f1b7020f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QObjectPrivate: use placement new/delete for SignalVectorThiago Macieira2022-04-131-2/+6
| | | | | | | | | Just to be pedantically correct, but also makes the construction code slightly more readable. Pick-to: 6.2 6.3 Change-Id: I29f1c141c0f7436393d9fffd16e2bbf0f361c024 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QObjectPrivate: use ConnectionList's constructor instead of copy-assignmentThiago Macieira2022-04-131-1/+4
| | | | | | | | | | | | | | | For all new elements, this is the correct thing to do. This seems to work around an MSVC compiler bug on ARM64. It also seems to generate better code for x86-64 too, as a nice bonus. See: https://developercommunity.visualstudio.com/t/codegen-elides-initializers-when-copying/10004323 Before: https://msvc.godbolt.org/z/Wcd4haaPd After: https://msvc.godbolt.org/z/vWYjazWGr, https://gcc.godbolt.org/z/hdsvTq9nE Fixes: QTBUG-102246 Pick-to: 6.2 6.3 Change-Id: I29f1c141c0f7436393d9fffd16e2bbbf4c0fe54d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QObject: restore flags printing in dumpObjectTree()Marc Mutz2022-03-191-0/+4
| | | | | | | | | | | | | | | | | | | | This was lost when QtCore, QtGui and QtWidgets were split up. Restored now via a virtual function on QObjectPrivate. Chose to return std::string instead of QString or QByteArray because its SSO is usually sufficient to hold these flag strings. [ChangeLog][QtCore][QObject] Restored printing of Qt3-style information from dumpObjectTree(). [ChangeLog][QtWidgets][QWidget] Restored printing of Qt3-style information from QWidget::dumpObjectTree(). Fixes: QTBUG-101732 Change-Id: I39ff5728ea5f5abbdbf81b5d7e13b8d16b6ee8b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Extract Method QObjectPrivate::ensureExtraData()Marc Mutz2022-03-151-0/+6
| | | | | | | | ... to centralize the creation of QObjectPrivate::extraData. Change-Id: I04e97779ceb0168fa7660e77e0dab2ed3e1ad03e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QProperty: fix threading issuesFabian Kosmale2022-03-101-1/+3
| | | | | | | | | | | | | | | | | | | | QObject's cache the binding status pointer to avoid TLS lookups. However, when an object is moved to a different thread, we need to update the cached pointer (as the original thread might stop and thus no longer exist, and to correctly allow setting up bindings in the object's thread). Fix this by also storing the binding status in QThreadPrivate and updating the object's binding status when moved. This does only work when the thread is already running, though. If it is not running, we instead treat the QThreadPrivate's status pointer as a pointer to a vector of pending objects. Once the QThread has been started, we check if there are pending objects, and update them at this point. Pick-to: 6.2 6.3 Fixes: QTBUG-101177 Change-Id: I0490bbbdc1a17cb5f85044ad6eb2e1a8c759d4b7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QObject: Q_ASSERT the object type before calling a PMFThiago Macieira2021-11-271-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Return a plain QMetaObject* from toDynamicMetaObject()Ulf Hermann2021-10-071-2/+2
| | | | | | | | | | | | | | | | | | | The only place where we use it, we swiftly cast it to QMetaObject* anyway. Generating an object with virtual methods, only to then cast to its non-virtual base type is dangerous. Also, if we are required to return a QAbstractDynamicMetaObject from a method of QDynamicMetaObjectData, we cannot implement QDynamicMetaObjectData without also implementing QAbstractDynamicMetaObject. This indirectly forces us to copy metaobjects around as we cannot wrap an existing metaobject into a QDynamicMetaObjectData subclass. Copying metaobjects around makes QMetaObject::inherits() unusable because inherits() assumes identity is determined by identity of the pointer. Change-Id: Icbe697efa6fd66649eef3c91260c95cda62e3c90 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QPrivateSlotBase: add empty base class optimizationMarc Mutz2021-07-291-5/+30
| | | | | | | | | | | | | | | There are few slots whose lambdas are empty; most will at least capture [this]. But there are a few in Qt examples that do, e.g. []{ qApp->quit(); }. Logging is also an example. So go the extra mile and optimize for empty functors by inheriting from them as opposed to storing them in a member variable. Change-Id: I3904f10db5ebe904ba889d29c08569edd804df3b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix crash in concurrent disconnectLars Knoll2021-06-171-3/+13
| | | | | | | | | | | | | | This does not fix all data races that we have in the system yet. One major issue is the virtual disconnectNotify(), that can be called from any thread and thus is inherently problematic, as it can collide with the object getting destroyed at the same time in another thread. Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-88248 Change-Id: I9d841eb363b7e4f0de1657aeb8f5340d0fd55190 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* cleanOrphanedConnectionsImpl: Allow to skip lockingFabian Kosmale2021-06-171-3/+10
| | | | | | | | | | | This function is/will be used in a few places where we already have a lock. Temporarily unlocking and relocking invites all kinds of troubles. By adding a flag we can instead tell the function that we already hold the lock. Pick-to: 6.2 6.1 5.15 Change-Id: Ibca089de61133661d5cd75290f2a55c22c5d013c Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QProperty: Do not involve semi-destroyed QObjects in bindingsFabian Kosmale2021-06-071-0/+2
| | | | | | | | | | | | | Once we're in ~QObject, only methods of QObject are still valid. Notably, no setter of any derived class is still valid. Thus, to be safe we must no longer react to binding changes of those properties. To ensure that this happens for QObjectCompatProperty properties, we explicitly clear the binding storage. Fixes a particles3d example crash. Change-Id: I10d2bfa5e96621ce039d751cffaf3ac41893623e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qobject_p.h: Do not use plain emitFabian Kosmale2021-04-221-1/+1
| | | | | | | It breaks tst_nokeywords in declarative. Change-Id: If3856f2fc657f142ed8e7c1da48fca0dba9a58fd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QObject: port to new property systemIvan Solovev2021-04-211-4/+27
| | | | | | | | | | | | | | | Extended QObjectPrivate::ExtraData to store a pointer to its parent, and reimplemented qGetBindingStorage() function for QObjectPrivate::ExtraData. This allows to use Q_OBJECT_COMPAT_PROPERTY macro for a property, stored in QObjectPrivate::ExtraData and solves all the problems with calling a custom setter. Task-number: QTBUG-85520 Change-Id: I40e01c29430846359ef9160fa1ae97c702be9a18 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QObject: remove QAbstractDeclarativeData::parentChangedFabian Kosmale2021-03-111-1/+0
| | | | | | | | The code in qtdeclarative did not do anything at all anymore. Change-Id: Idd97145cb74aeb4f43dfce2f282a765e90945073 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add new special QObjectPrivate::{connect, disconnect} for QMLAndrei Golubev2021-01-181-0/+6
| | | | | | | | | | | | | | | | 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 Pick-to: 5.15 6.0 Change-Id: I4580d75b617cb2c4dfb971a4dfb8e943e325572b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Inline access to the QBindingStorageLars Knoll2020-11-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Change-Id: Ifd1fa3a489c3be8b1468c0b88af547aac397f412 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 98c82fb445acf45cc4c4bc86a5adda43358127bf) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-3/+3
| | | | | | | | | | | | | | 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. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Whitespace cleanup in corelib/kernelAllan Sandfeld Jensen2020-10-241-14/+15
| | | | | Change-Id: If061ef0af5ced4384e20a82afcea3712fa7e45d7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add a QBindingStorage classLars Knoll2020-09-021-0/+12
| | | | | | | | | | | | | | | | | | | QBindingStorage is a class that can store a set of binding objects for the properties of a QObject. This will get used to reduce the memory overhead of the property system when adding bindable properties to QObject based classes. The binding storage has a pointer to the TLS entry containing the currently evaluating binding. Like that we avoid repeated TLS lookups and reduce the overhead of the property system to one pointer lookup and one compare for the case that properties aren't being used. Each QObject now owns one binding storage object, that can be used to store binding data for properties that members of the QObject. Change-Id: I27427c03c2ba281f072e074be96147bdbcaac246 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QObject: add a single shot connection flagGiuseppe D'Angelo2020-09-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If one needed to listen to a signal just once, one had to store the QMetaObject::Connection object returned by connect() and use it to disconnect the slot after the first signal activation. This has led to a proliferation of using wrappers (and enough TMP); they usually look like this: 1) create a shared_ptr<QMO::Connection>, allocating its payload; 2) create a lambda, capturing the shared_ptr by value; 3) in the lambda, disconnect the connection (through the shared_ptr), and call the actual slot; 4) connect the signal to the lambda, storing the returned QMO::Connection into the shared_ptr. This is expensive, error prone for newcomers, and tricky to support as a general facility inside one's projects. We can do better, just support single shot connections right in QObject. [ChangeLog][QtCore][QObject] Added the Qt::SingleShotConnection flag. When a connection is established with this flag set, the slot is going to be activated at most once; when the signal is emitted, the connection gets automatically broken by Qt. Change-Id: I5f5feeae7f76c9c3d6323d841efba81c8f98ce7e Fixes: QTBUG-44219 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Use QMetaType in QMetaCallEventLars Knoll2020-08-241-3/+3
| | | | | | | And don't use int based type mapping anymore. Change-Id: I456e76d1933ef646a7bd39ce565886b89e938a44 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid warnings regarding bit-field signednessDimitrios Apostolou2020-07-161-1/+1
| | | | | | | | | | | Up to (including) C++11, integral bitfields of unspecified signedness have implementation dependent signedness. Detected by LGTM.com static analyzer. Pick-to: 5.15 Change-Id: Ibaa0fdc6e443495a3cd40330c4573c9cc6ccdf5b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QList instead of QVector in corelibJarek Kobus2020-06-251-6/+5
| | | | | | | | | | Applied to headers only. Source file to be changed separately. Omitted statemachine for now to avoid conflicts. Omitted qmetatype.h for now - to be handled later. Task-number: QTBUG-84469 Change-Id: I317376037a62467c313467d92955ad0b7473aa97 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-6/+6
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>