aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/pysideproperty.cpp
Commit message (Collapse)AuthorAgeFilesLines
* libpyside/libpysideqml: Introduce flags for property argumentsFriedemann Kleint13 days1-53/+29
| | | | | | | | | This allows for removing a number of free functions and eventually better separating QmlListProperty from Property. Task-number: PYSIDE-3227 Change-Id: If2806f86bbbb615e59655d4f9a19b0fe87219fb5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libpyside/libpysideqml: Refactor property argument parsingFriedemann Kleint14 days1-33/+51
| | | | | | | | | | | | | | Take over arguments only if they are neither null nor Py_None and simplify checks accordingly. Make the error message more precise. With that 2aff6a35a9aa2f233c9801456daa6986437d2647, can be partially reverted. Task-number: PYSIDE-3227 Change-Id: I335db395e969415022581e1ec95a7e3715725bf1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libpyside: Introduce a helper function for creating propertiesFriedemann Kleint14 days1-0/+32
| | | | | | | For use in QtRemoteObjects and Python bridges. Change-Id: Ica4d3c36cc87db958353d7d6de25806acdf5d8b7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6/Property: Fix read-only properties when using the decorator syntaxFriedemann Kleint2025-11-031-5/+6
| | | | | | | | | | | The @setter decorator causes the property to be recreated with Py_None set for the non-existent members, apparently due to a long-closed Python bug (see_property_copy()). As a band-aid fix, check for Py_None. Fixes: PYSIDE-3227 Pick-to: 6.10 Change-Id: Ib818e9930bd598306270377e26e625bfa9692a92 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Add PepModule_AddType()Friedemann Kleint2025-09-031-1/+1
| | | | | | | | | | | | | PyModule_AddObject() is deprecated in 3.13. For adding types to a module, PyModule_AddType() can be used instead (added to stable ABI in 3.10). Add a Pep function for it. This requires adapting some type names in QML. Pick-to: 6.9 6.8 Task-number: PYSIDE-3147 Change-Id: I169a6b7071c780dd3c3ec2ddd0762dca6cacf067 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix compilation with Python 3.14/raised limited API/PyObject parametersFriedemann Kleint2025-09-031-3/+5
| | | | | | | | | | Some macros (Py_INCREF/Py_TYPE) were reimplemented as functions, unearthing some type incompatibilities. Pick-to: 6.9 6.8 Task-number: PYSIDE-3147 Change-Id: If10bc5941d718d8845c7bbd5facf6021539aad34 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* type hints: Correct the type annotation of the notify parameter in ↵Ece Cinucen2025-08-281-1/+1
| | | | | | | | | | | | | QtCore.Property - The stub previously declared notify as Optional[Callable[[], None]], but at runtime notify must be a Signal (emitted when the property changes), never a Callable. - This caused errors in type checkers when passing a Signal to notify. - The annotation is now updated to Optional[Signal] Pick-to: 6.8 6.9 Fixes: PYSIDE-2308 Change-Id: Ie42e220c51dc0419524b9dc5696371f03c42cad9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix crash retrieving a PyObject type property via QVariant<PyObjectWrapper>Friedemann Kleint2025-05-191-9/+16
| | | | | | | | | | | | | | | | | | | | | 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>
* type hints: Correct type signature for Property classEce Cinucen2025-04-031-4/+4
| | | | | | | | Task-number: PYSIDE-3012 Pick-to: 6.8 6.9 Change-Id: I720dd730f6dd28ae33a6019494b7b67b8f704a10 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Fix includes of libshibokenFriedemann Kleint2025-03-261-1/+5
| | | | | | | | | Remove the global header <shiboken.h> in favor of the respective headers. Pick-to: 6.9 Change-Id: I08ee39fbd5abb15741fa5746bb82f9ddcd32ed7f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Improve type annotations, first stepEce Cinucen2025-02-271-10/+10
| | | | | | | | | | Import Callable, Iterable and Sequence from collections.abc, since using them from typing is deprecated. Pick-to: 6.8 Task-number: PYSIDE-3012 Change-Id: I131c00005df410fdaa40b338a2a728512269aaa0 Reviewed-by: Christian Tismer <tismer@stackless.com>
* limited api: Remove PyTuple_GET_ITEM, PyTuple_SET_ITEM, and PyTuple_GET_SIZE ↵Cristián Maureira-Fredes2024-11-081-7/+7
| | | | | | | | | | | macros Removing old macros for compatibility with the limited api, and refactoring some of their usages Change-Id: I33954199d2ef9884c64b963863b97aed851c440f Pick-to: 6.8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* type hints: Fix typing.Callable to include parametersChristian Tismer2024-10-171-9/+13
| | | | | | | | | | All callables have now arguments. Task-number: PYSIDE-2846 Fixes: PYSIDE-2884 Change-Id: Ibf6b1d93350304550addbc459c1440bd5cefc057 Pick-to: 6.8 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PySide6-property: Improve error handlingFriedemann Kleint2024-10-161-1/+1
| | | | | | | | | | | PyArg_ParseTupleAndKeywords() can return Py_None for invalid types in the property decorator, for which getTypeName() returns "void". Set an error in this case. Pick-to: 6.8 Task-number: PYSIDE-2840 Change-Id: I98a497df445d9b543dddaa495d85042e00673e78 Reviewed-by: Christian Tismer <tismer@stackless.com>
* libshiboken: Remove PepRuntime_38_flagFriedemann Kleint2024-08-061-5/+3
| | | | | | | Python 3.9 is now the minimum version. Change-Id: I7d519cf4b73516ee0d659e377805e2b6f96402d2 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* libpyside: Fix static analysis warningsFriedemann Kleint2024-06-241-24/+30
| | | | | | | | | | | | | | | | - 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>
* pyi: Fix checking errors on the property decoratorFriedemann Kleint2024-05-291-0/+1
| | | | | | | | | Add the __call__ operator. Fixes: PYSIDE-2767 Pick-to: 6.7 6.5 Change-Id: Ic73df2918fb8effaceeddbcb2c92f7ac7eb861c5 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Use PyType_GetSlot() instead of accessing PyTypeObject's slots in library codeFriedemann Kleint2024-01-161-2/+3
| | | | | | | | | | Using PepType_GetSlot() as is requires adding ugly casts. To work around, add a new file with convenience helper functions in C++ linkage. This also allows for using templates for tp_alloc. Task-number: PYSIDE-560 Change-Id: Ia50a226f5b545861f885d600445b91b4e11713c5 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Unify the structure of type creation functionsChristian Tismer2023-10-251-22/+26
| | | | | | | | | | | | | | | | It is the better concept to use the same structure for all type creation functions. We move the type slots and type specs into these functions. The calling function then always has the same structure of one static expression and returning the type. This might also save some space for shatic structures. Task-number: PYSIDE-2230 Change-Id: Ib972f210f44422eb1ebe47a0d92ac18a8377ac87 Pick-to: 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Support running PySide on Python 3.12Christian Tismer2023-10-091-2/+2
| | | | | | | | | | | | | | | | | | Builtin types no longer have tp_dict set. We need to use PyType_GetDict, instead. This works without Limited API at the moment. With some great cheating, this works with Limited API, too. We emulate PyType_GetDict by tp_dict if that is not 0. Otherwise we create an empty dict. Some small changes to Exception handling and longer warm-up in leaking tests were found, too. Pick-to: 6.6 6.5 6.2 Task-number: PYSIDE-2230 Change-Id: I8a56de6208ec00979255b39b5784dfc9b4b92def Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* libshiboken/libpyside: Fix special functionsFriedemann Kleint2023-10-061-0/+1
| | | | | | | | 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>
* libshiboken/libpyside: Fix some static analysis warningsFriedemann Kleint2023-09-201-4/+4
| | | | | | | | | | | | - nullptr - narrowing integer conversions - else after return - Use auto - Missing move special functions Pick-to: 6.6 6.5 Change-Id: Ib872481a46c8bb17592cdc1778ab3c4d9598c753 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Fix namespacesFriedemann Kleint2023-09-201-8/+2
| | | | | | | | | | | - Use nested namespaces instead repetitive namespace declaration - Remove anonymous namespaces that contain only static functions. "static" is sufficient here, the anonymous namespace only increases compilation time. Pick-to: 6.6 6.5 Change-Id: I6cd1b63da79eaf40a1b7ae031def97fa22903e99 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* property: fix an old refcount bug, concluding debug errorsChristian Tismer2023-02-201-4/+11
| | | | | | | | | | | | | | | | There was a refcounting bug in pysideproperty.cpp that took some time to be understood. By using Property.__init__ multiple times, an omission became manifest: Not clearing a Property instance's attribute before generates a leak. This was the last unsolved reference bug in debug mode :-) Change-Id: Ie91fa9e56ef52ca555168841c99c14fd550202ed Fixes: PYSIDE-1402 Pick-to: 6.4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* property/QML: Improve handling of an unknown class nameChristian Tismer2023-01-061-9/+18
| | | | | | | | | | | | | | | | | pysideproperty has Q_ASSERT calls, which cause errors when a typename is undefined. This behavior is inconsistent and should either raise an exception or be circumvented. For compatibility with another implementation, unknown types are now ignored, and debug and release are consistent. To obtain an error, run the script with -Werrors . This makes use of the new exception delay feature. Task-number: PYSIDE-2160 Change-Id: Ia320edab4b51dd6f6b94a429b8f1f086ce9897f7 Pick-to: 6.4 6.2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix Property GC tracking for Python 3.11Christian Tismer2022-09-121-0/+2
| | | | | | | | | | The GC was not untracked when PySide Property was deleted. This was found by the new deeper error tracking in debug Python 3.11 . Fixes: PYSIDE-1960 Change-Id: I5ecdfb88529c22a44575ca9460d6753b1e389079 Pick-to: 6.2 6.3 5.15 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* 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>
* Fix endless recursion querying __doc__ of a propertyFriedemann Kleint2022-03-281-1/+1
| | | | | | | | | | Add a check for None Pick-to: 6.2 5.15 Fixes: PYSIDE-1874 Change-Id: I0127ba77ef2017dae232f2a1db1410d9cfe62405 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Store the type object in PySidePropertyFriedemann Kleint2022-03-031-3/+9
| | | | | | | | | The exact type information is required for QML grouped properties. Task-number: PYSIDE-1836 Change-Id: Id24cc1db355cee6fea88dfb4c1a67904c7e37bf3 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add explanatory comment to PySidePropertyFriedemann Kleint2022-03-031-0/+3
| | | | | | | | | | Amends d3883e9186892e673e8a66ad6651409d5eaf7cf3. Pick-to: 6.2 Task-number: PYSIDE-1402 Task-number: PYSIDE-1836 Change-Id: I8bbdb2a4f4d82786d15db85b3b8e364b9df35d8a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Refactor handling of QmlListPropertyFriedemann Kleint2022-02-241-89/+75
| | | | | | | | | | | | | PySidePropertyPrivate had a function pointer for the meta call handler that was set to an internal function for most properties. QmlListProperty would set it to a different function along with user data. Turn this into a virtual function of PySidePropertyPrivate and override it in QmlListPropertyPrivate. The function pointer and the user data pointer can then be removed. Task-number: PYSIDE-1827 Change-Id: I9c6452e2d39d5fd9b14d4c74ab7ed2fad483af29 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Refactor SignalManager::qt_metacall()Friedemann Kleint2022-02-241-3/+0
| | | | | | | | | | | | | The logic of SignalManager::qt_metacall() instantiated a number of variables that were only relevant for properties in each call and locked and released the GIL multiple times. Split it apart into separate handler for properties and method invocations and reduce the GIL allocations. Task-number: PYSIDE-1827 Change-Id: I171853d1bd95dc3d8437c64075448a08af2ea7e0 Reviewed-by: Christian Tismer <tismer@stackless.com>
* PyPySide: Rename interface functions and classes to simplify debuggingChristian Tismer2022-02-031-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | The names of certain interface functions are not always following a simple scheme. Especially it is not easy to see immediately if we are dealing with a method of SbkObjectType or SbkObject Do a few renamings to simplify debugging and make the code easier to understand. When a function is used in a type spec and there is no other important reason, it should be named like {Py_<tpname>: reinterpret_cast<void *>(<TypeName>_<tpname>)}, Rename also all type functions ending on "TypeF()" to end in "_TypeF()". This is not always the case. Examples: SbkObjectTpNew -> SbkObject_tp_new SbkObjecttypeTpNew -> SbkObjectType_tp_new PyClassPropertyTypeF -> PyClassProperty_TypeF Task-number: PYSIDE-535 Change-Id: Icbd118852f2ee732b55d944ed57c7a8ef7d26139 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* libpyside: Remove unused dynamicqmetaobject_p.hFriedemann Kleint2022-01-071-1/+0
| | | | | Change-Id: I4aef7765fc2647cd597fb316535fe28dc43cef01 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Improve the MyPy support, first systematic changesChristian Tismer2021-10-191-2/+1
| | | | | | | | | | * hand-crafted class signatures don't have a return type (__init__) * make optional typing imports complete * skip imports which are defined in the same module Task-number: PYSIDE-1675 Change-Id: I30950e16347158804430e04f93254f0177d2a506 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyPySide: Encapsulate type generation to be PyPy compatibleChristian Tismer2021-09-151-1/+1
| | | | | | | | | | | | | | | | | | Type generation in PyPy is critical. When type creation calls PyType_Ready, PyPy freezes the current state of the type object. That has fatal effects, because with the Limited API, we need to patch some types a little _after_ creation. The functionality of this patch is still the same, but type creation is totally encapsulated, and we can do a different implementation for PyPy. [ChangeLog][PySide6] PyPySide: Type creation was completely encapsulated. The implementation can now be rewritten for PyPy. Task-number: PYSIDE-535 Change-Id: Iae0cadb15b631344ae76cea8c104d4b69941c2b0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Shiboken: Change type(SbkType_FromSpec) to PyType_ObjectChristian Tismer2021-09-131-2/+1
| | | | | | | | | | | | This step prepares the transition of type generation to PyPy compatibility. [ChangeLog][shiboken6] SbkType_FromSpec() has been changed to return a PyType_Object *. Task-number: PYSIDE-535 Change-Id: I74e2e527e66a41f1a9f3f911f44d641139371889 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyClassProperty: Correct the decorator and publish the classChristian Tismer2021-06-101-9/+5
| | | | | | | | | | | | | | PyClassProperty is now correctly published as a QtCore class and existing as an import. As a side effect, a bug was fixed where a syntax error occurred because of a missing signature count. Task-number: PYSIDE-1019 Fixes: PYSIDE-1593 Change-Id: Iae733280d9f9c23244e83a356011104bf527c329 Pick-to: 6.1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* libpyside: Fix some clang analzyer warningsFriedemann Kleint2021-03-111-20/+20
| | | | | | | | | | | | - Use nullptr - Initialize variables - Remove else after return - Remove C-style casts - Avoid constructing QString from const char * - Use emit for signals Change-Id: I6ba8cad51f4b2a22f94996d1a9d8c3ae87c35099 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Clean up some warnings produced by Qt Creator's clang/clazy code checkersFriedemann Kleint2021-01-211-2/+0
| | | | | | | | | | - Remove unused variables - Remove assignments that do not have any effect - Fix mixing const/non-const iterators - Fix for loops, use const ref and/or qAsConst() Change-Id: I4b52f11030493c440026b194f18ec0151a3ea710 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* property: fix an eight year olde bug that showed after the overhaulChristian Tismer2020-11-261-3/+4
| | | | | | | | | | | | | | | | | | | | | | The modernisation of pysideproperty.cpp creates an error when using @Property(str, constant=True) This could also be provoked before the improved version of Property by def getVal(self): return self.val variable = Property(str, getVal, constant=True, fset=None) because the None/NULL - handling was incomplete. Change-Id: Ib39dd3bdb62ba928164faa465ee3dd743262e245 Fixes: PYSIDE-1426 Pick-to: 5.15 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* pysideproperty.cpp: Fix compilation with MSVC2019/C++ 17 modeFriedemann Kleint2020-11-261-7/+6
| | | | | | | | | It does not accept a ternary operator with QByteArray/const char * arguments. Pick-to: 5.15 Change-Id: I02bcb740100c4568ecb262fa6ecf3d466e02c875 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Rename PySide2 to PySide6Friedemann Kleint2020-11-021-0/+634
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>