aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/signalmanager.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash retrieving a PyObject type property via QVariant<PyObjectWrapper>Friedemann Kleint2025-05-191-0/+2
| | | | | | | | | | | | | | | | | | | | | The old code registered a Shiboken converter for PyObjectWrapper by pointer conversion. This resulted in the Python to C++ converter falling back to plain pointer passthrough since it only works for SbkObjects. The C++ to Python conversion worked by coincidence for either raw PyObject * pointers used in meta call handling or pointers obtained from calling QVariant<PyObjectWrapper>.data(), but without handling reference counts. To fix this, remove the Python to C++ conversion entirely and do this manually via QVariant. Change the C++ to Python to be by value and use PyObjectWrapper. Fixes: PYSIDE-2193 Pick-to: 6.9 Change-Id: I00898894651f220d7b8fe60608e93233ef3e6493 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* libpyside: Add a debug operator for PyObjectWrapperFriedemann Kleint2025-05-161-0/+2
| | | | | | | | | This useful for debugging QML issues. Task-number: PYSIDE-2193 Pick-to: 6.9 Change-Id: Iecbfb1d9508ac89c8b213a2f2ee8d4f7f1de4fc8 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* libpyside: Make PyObjectWrapper movableFriedemann Kleint2025-05-131-2/+2
| | | | | | | | | This is required by today's QVariant conversion code. Task-number: PYSIDE-2193 Pick-to: 6.9 Change-Id: I66efcfb797653fe1d617f1f0027fd60ec95e8a79 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PySide6: Port to Qt include styleFriedemann Kleint2025-03-271-1/+1
| | | | | | | | | Replace the Qt forwarding headers by the .h files. This brings down the dependency list by approx 6%. Pick-to: 6.9 Change-Id: Iae7640ccbdf6a8be68137922d4191522d914d790 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libpyside: Fix some clang-tidy warningsFriedemann Kleint2025-02-031-0/+1
| | | | | | | | - Remove superfluous casts Pick-to: 6.8 Change-Id: I8dd7cdd1e9d3f30103fc6d87bf04d7f0d0182603 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Fix error handling in non-slot connection receiversFriedemann Kleint2024-10-211-0/+1
| | | | | | | | | | | | | | | Extract the error handling code which existed duplicated in GlobalReceiverV2::qt_metacall() and SignalManagerPrivate::handleMetaCallError() as a static helper of SignalManager and call that from the DynamicSlot functions. Amends 33bd61d13d8d9e3794b6049891be62f3351313d9. Pick-to: 6.8 6.8.0 Task-number: PYSIDE-2810 Fixes: PYSIDE-2900 Change-Id: Ife9f156e6752dde7002218d36d369ba68ad595b0 Reviewed-by: Christian Tismer <tismer@stackless.com>
* libpyside: Reimplement signal connections for Python callables not targeting ↵Friedemann Kleint2024-08-211-19/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | a QMetaMethod The code previously used a instances of class GlobalReceiverV2 inheriting QObject in a hash in SignalManager per slot tracking the list of senders to be able to use standard signal/slot connections in Qt. This was a complicated data structure and had issues with cleanups. This has been replaced by using an invoker object based on QtPrivate::QSlotObjectBase which can be passed to QObjectPrivate::connect(const QObject *, int signal, QtPrivate::QSlotObjectBase *, ...). The connections (identified by ConnectionKey) are now stored in a hash with QMetaObject::Connection as value, which can be used to disconnect using QObject::disconnect(QMetaObject::Connection). Deletion tracking is done by using signal QObject::destroyed(QObject*) which requires adapting some tests checking on the connection count and weak ref notification on receivers as was the case before. [ChangeLog][PySide6] Signal connections for Python callables not targeting a QMetaMethod has be reimplemented to simplify code and prepare for removal of the GIL. Task-number: PYSIDE-2810 Task-number: PYSIDE-2221 Change-Id: Ib55e73d4d7bfe6d7a8b7adc3ce3734eac5789bea Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libpyside: Refactor signature handling in GlobalReceiverV2Friedemann Kleint2024-07-091-1/+1
| | | | | | | | | | | | Move the signatures hash from DynamicSlotDataV2 into GlobalReceiverV2 to avoid unnecessary indirections and to enable further refactorings of DynamicSlotDataV2. Use QByteArray for the signature parameters, avoiding the conversion. Task-number: PYSIDE-2810 Change-Id: I17a637e28e9dac4ea159b26a375e8c1535e00814 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* libpyside: Pass MetaObjectBuilder signature as QByteArrayFriedemann Kleint2024-07-091-2/+6
| | | | | | | | | | | | | | Change the MetaObjectBuilder::addSlot()/addSignal() functions to use a QByteArray since the underlying QMetaObjectBuilder takes QByteArray, too. Split SignalManager::registerMetaMethodGetIndex() into overloads for const char * (for the signal code path) and QByteArray (for the slot code path). Task-number: PYSIDE-2810 Change-Id: Ie79ea071a8cc111d45248c7086cf6fda34a7548f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* libpyside: Decouple SignalManager::callPythonMetaMethod() from QMetaMethodFriedemann Kleint2024-07-041-2/+5
| | | | | | | | Extract a helper for calling Python slots and add an overload that only takes a list of parameter types and return type. Change-Id: I407c3b1ae66eb4f01370ceac3112eb9407796efa Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libpyside: Fix static analysis warningsFriedemann Kleint2024-06-241-2/+2
| | | | | | | | | | | | | | | | - Initialize variables - Use auto * - Remove repeated return types - Fix else after return - Fix some invocations of static methods - Make functions const/static where appropriate - Fix some int types to avoid lossy conversions - Use Py_RETURN_NONE where appropriate - Minor cleanups - Remove some macros Change-Id: I7fa7a29e7b3dc47037027978001824e0709d001f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* libpyside: Remove short circuit signal handlingFriedemann Kleint2024-05-271-1/+1
| | | | | | | | | | | There was a "Short circuit" code path triggering on QMetaMethod signal signatures without parentheses, which is apparently dead. Task-number: PYSIDE-2667 Change-Id: I68c4c636ea224a7691e76286ed43f5aaaa6d4bd7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* libpyside: Clean up lambdas connected to signals earlier in shutdownFriedemann Kleint2024-03-251-0/+1
| | | | | | | | | | | Run a signal handler cleanup in CoreApplication::aboutToQuit() already before the general cleanup. This prevents them from leaking out of a main() function, for example. Task-number: PYSIDE-2646 Pick-to: 6.7 6.6 6.5 Change-Id: I87cce8d131c40c02b44b0102b3774477676b8f89 Reviewed-by: Christian Tismer <tismer@stackless.com>
* libpyside: Fix spelling error in function nameFriedemann Kleint2024-03-251-1/+1
| | | | | | | | | | Amends 1270a9e82e5bc3bd53a1131698ece60403da1192. Task-number: PYSIDE-2646 Task-number: PYSIDE-2141 Pick-to: 6.7 6.6 6.5 Change-Id: Ib8a5146766166ec4fa7ae7b42ce6d52ccae0b3c6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* libshiboken/libpyside: Fix special functionsFriedemann Kleint2023-10-061-1/+2
| | | | | | | | Pick-to: 6.6 Task-number: PYSIDE-2479 Change-Id: I6df19d487be7087f17e37bea3ea30a66e9b24ed7 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Enum: Enable toInt for QVariant(PyEnum/SbkEnum)Shyamnath Premnadh2023-06-131-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | - For Python/Shiboken types not known to Qt that requires wrapping around a QVariant, we use the PyObjectWrapper type. This patch registers a toInt() QMetaType converter for PyObjectWrapper, which enables automatic conversion to int for a QVariant(PyObjectWrapper) within C++ i.e. QVariant(PyObjectWrapper).toInt() will work - This means that cases like QAbstractItemModel::data() that calls QtPrivate::legacyEnumValueFromModelData(const QVariant &data) would work without explicit conversion from QVariant(PyObjectWrapper) to QVariant(int). But for cases like QMetaProperty::write() explcit handling is still required. - This would also work for cases where the QVariant(PyObjectWrapper) is simply channeled from Python to C++, and from C++ back to Python without performing any operations on it. - Incase, the wrapped object is not a PyEnum/ShibokenEnum object, then toInt() would return a -1. Pick-to: 6.5 Task-number: PYSIDE-1930 Task-number: PYSIDE-2339 Change-Id: I983351f2ff88c79c29399c257e38421116efc7a3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix QObject::sender() for non-C++ slotsFriedemann Kleint2022-12-121-1/+1
| | | | | | | | | | | | | | | For non-C++ slots routed via GlobalReceiverV2, sender() of the receiving QObject returns 0. To fix this, store the sender obtained in GlobalReceiverV2::qt_metacall() temporarily in a special dynamic property of the receiver and inject code checking it into QObject::sender(). This fixes at least the synchronous calls. Fixes: PYSIDE-2144 Fixes: PYSIDE-1295 Change-Id: Ia111162eb1404914ecfb7f19fadb8a1b63ae8b4a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix a crash when deleting QObject instances with connections in threadsFriedemann Kleint2022-12-081-3/+2
| | | | | | | | | | | | | | | | | | | GlobalReceiverV2 connected to the destroyed() signal of the senders to keep track of its lifetime, which caused issues with delayed emission of signals when using threads. To fix this, change GlobalReceiverV2's sender list to use QPointer, which automatically tracks the lifetime of the pointees. Move the deletion of the GlobalReceiverV2 instances into SignalManager, completely, removing the "delete this" pattern used. This allows for removing some hacks for the QObject::receivers() function. Fixes: PYSIDE-2141 Change-Id: I361256f919dab13bfcf20800624b2454308bbc4b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use SPDX license identifiersLucie Gérard2022-05-271-38/+2
| | | | | | | | | | | 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: I065150015bdb84a3096b5b39c061cf0a20ab637d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libpyside: Move helper isCompiledMethod() to pysideutils.hFriedemann Kleint2022-01-191-2/+0
| | | | | | | | | | | It appears to be a general use helper function which could be useful outside signalmanager as well. Amends 56f66f128566bd08f027fee46bb42a6c4f57a26e. Task-number: PYSIDE-1755 Change-Id: I449243bb5d800ba4d271b3079ad394810d468312 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Safe distinction of Nuitka compiled methodsShyamnath Premnadh2022-01-181-0/+2
| | | | | | | | | | | | | | | | | | Adds an extra check to see if __code__ is present. As mentioned in PYSIDE-1755, Mocks are callable objects without __code__ attribute, unlike Python Method or Functions. However, a Mock also has im_func__ and im__self attributes. We made the assumption __code__ would be present if im_func and im_self are present, and this makes it fall under the category of a compiled method. This patch makes an extra check to see if __code__ is present. If it is not, then the Slot (here Mock) is considered as a callable method. Task-number: PYSIDE-1755 Pick-to: 6.2 Change-Id: If7e8f52dfb2409cd856eec0d0b41891d751d8a69 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide6: Remove QML dependency from libpysideFriedemann Kleint2021-11-111-0/+6
| | | | | | | | | | | | | | Remove the QML error handling from SignalHandler by introducing a function pointer for this which can set from the QML module. This allows for removing QtQml from the libpyside dependencies, removing the need to deploy the QtQml libraries with widget applications. [ChangeLog][PySide6] libpyside no longer depends on QtQml. Change-Id: Iae7dabdd38ea03156f4c00073d84e42ec5a3d892 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Rename PySide2 to PySide6Friedemann Kleint2020-11-021-0/+121
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>