aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/libshiboken/basewrapper.cpp
Commit message (Collapse)AuthorAgeFilesLines
* libshiboken: Improve error handling when basic type creation failsFriedemann Kleint6 days1-4/+21
| | | | | | | | | | | Crashes have been observed on Fedora40 using Python 3.12.3.2 due to nullptr being passed to PyType_Ready(). Check for nullptr as well and try to retrieve the Python exception. Pick-to: 6.7 Task-number: PYSIDE-2747 Change-Id: Idb9565fa4bc1da78fcbbd5aeeec7cbe9758b1709 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* Also check the downcast for types found by dependency graph lookupFriedemann Kleint7 days1-1/+2
| | | | | | | | | | | | | Try to be on the safe side. This should trigger only in very rare cases (polymorphic ids used for hierarchies with non-virtual desctructors spanning multiple inheritance or when manually calling newObjectWithHeuristicsHelper() without type name). Amends 28d04cae204881392ddc0826a570d05ba82c5ee0. Task-number: PYSIDE-868 Change-Id: I25189b33ec7e3c6da2ca55d0560f97f1d6227f00 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Make multiple inheritance cast check less restrictiveFriedemann Kleint2024-05-061-1/+21
| | | | | | | | | | | | | | | | The old code would not allow to downcast if a special cast function exists somewhere in the class hierarchy (as is the case for example for QWidget inheriting QObject and QPaintDevice). Make the check more fine-grained by actually checking whether the base class is a direct, single line inheritance base class of the type passed in. This makes the mechanism work for widgets. The corresponding test can then be relaxed. Task-number: PYSIDE-868 Change-Id: Id81fd9c3080e42009fc84e06a9bab1c8856f2c0c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix polymorphic discovery to work without namesFriedemann Kleint2024-05-061-2/+4
| | | | | | | | | | In newObjectWithHeuristics(), try the type discovery graph check for the inherited class also in case the typeName is identical to the base name (which means typeid() was not able to do resolution based on virtual tables). Change-Id: Ia8912a4860a580418438f659b7a854647657ab9a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libshiboken: Split the Shiboken::Object::newObject() functionFriedemann Kleint2024-05-061-9/+48
| | | | | | | | | | | | | | | | | | | Remove the bool exactType parameter from the existing newObject() by splitting it into 3 functions: newObjectForType() creates an instance for the type passed in. newObjectWithHeuristics() takes an additional typeName parameter obtained from typeid().name() on the C++ pointer which may contain the derived class name and also tries to find the most derived class using the type discovery graph. newObjectForPointer() is new and contains a test for multiple inheritance in the inheritance tree (disabling use of the most derived class) which was previously generated into the code. Change-Id: Ic0a25f8ec17dc20364b37062de6f20544cd2f09e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PEP 697: Use the new type extension provision, finalChristian Tismer2024-05-021-2/+0
| | | | | | | | | | | | | | | | | | | The new embedded extra fields were not correctly addressed when a subclass of the meta type was used. This was fixed by using SbkObjectType explicitly instead of the type of an object which might be derived. This also explains the complexity of the Python API. The famous bug_825 is now fixed, too. Checked with Valgrind on Ubuntu. Task-number: PYSIDE-2230 Change-Id: Icf99ed6faab226c72bdd09f4c69018d958ede85e Fixes: PYSIDE-2676 Pick-to: 6.6 6.7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Revert "PEP 697: Use the new type extension provision, amended"Christian Tismer2024-05-021-33/+5
| | | | | | | | | | | This reverts commit adb609270e54177024fbcbd9aab7f168a7205dec. Reason for revert: The real fix is much simpler and complete. Change-Id: I07171bcd28fd3f9aa21ddde3130b755aecb62e7d Pick-to: 6.6 6.7 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* libshiboken: Refactor base type visitorFriedemann Kleint2024-04-301-69/+76
| | | | | | | | | | | | | | | | Replace the walkThroughClassHierarchy() function using HierarchyVisitor-derived class by a template function walkThroughBases() taking a predicate. The name walkThroughClassHierarchy() was misleading since it really only visits the first level of base classes relevant for C++ object allocation. Make the functions using it static except getNumberOfCppBaseClasses() which is used outside basewrapper.cpp. Change-Id: Id3b7e81d6d6a6c4a4eae7322ec1a9f151f5d5ae1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Lazy-initialize the dependency graphFriedemann Kleint2024-04-251-5/+0
| | | | | | | | | | | | | | | | | | | | | Change the dependency graph in the BindingManager from PyTypeObject *-based nodes to nodes which are wrapping the TypeInitStruct * and hashing on the type name. This allows for creating the types on demand when walking along the edges and calling the type discovery functions. This only creates the required types instead of the entire lazy group of polymorphic classes. The graph is now populated by from the generated code using a function named initInheritance() instead of dynamically from introduceWrapperType. Task-number: PYSIDE-2404 Task-number: PYSIDE-2675 Pick-to: 6.7 Change-Id: I030d4957c221f4defbb7cc52a6927287b70d9864 Reviewed-by: Christian Tismer <tismer@stackless.com>
* libshiboken: Refactor type discovery graph handlingFriedemann Kleint2024-04-251-3/+8
| | | | | | | | | | | | | | | Replace BindingManager::.resolveType() by a new function BindingManager::findDerivedType() which does exactly that and returns a pair of type/cptr instead of modifying the in-parameter. As a drive-by, remove a unused variable in BindingManagerPrivate. Task-number: PYSIDE-2404 Task-number: PYSIDE-2675 Pick-to: 6.7 Change-Id: I5b39ea8370b0fc1a196feb6934306f1f1dfeb8b3 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PEP 697: Use the new type extension provision, amendedChristian Tismer2024-04-241-5/+33
| | | | | | | | | | | | | | | | The new embedded extra fields were not correctly initialized. For that, an extra meta class was necessary. This bug could not be seen on macOS, probably due to other memory allocation rules. The famous bug_825 is now also fixed. Change-Id: I44ee3b363dda77c4e21951fe2a5385c0368df0cb Task-number: PYSIDE-2230 Fixes: PYSIDE-2676 Pick-to: 6.6 6.7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Fix leaking tuples in introduceWrapperType()Friedemann Kleint2024-04-241-6/+5
| | | | | | | | | | | | | | | | | When calling introduceWrapperType(), the generated code creates and leaks a tuple of base types if there are base classes. When there are no base classes, a tuple (containing SbkObjectType) is created and leaked within introduceWrapperType(). To fix this, generate the complete tuple including SbkObjectType in the generated code and remove the base type parameter to introduceWrapperType(). Pick-to: 6.7 Task-number: PYSIDE-1617 Change-Id: Ib3bec8e6b94bea14a46df826667373d3f859dfd5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* LazyInit: Implement Lazy Initialization by Delayed Module EntriesChristian Tismer2024-03-131-0/+1
| | | | | | | | | | | | | | | | | | | | Lazy init is done by module entries which are delayed. Although visible in the module, the classes are only created when actually accessed by getattr. Internally, the access to the global Init_xxx functions is redirected to a Shiboken::Module::get function which resolves the classes if not already present in the global type array. PYSIDE6_OPTION_LAZY 0 - no lazy loading 1 - lazy load all known modules 2 - lazy load all modules Task-number: PYSIDE-2404 Change-Id: I98c01856e293732c166662050d0fbc6f6ec9082b Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Deprecation Python 3.8Cristián Maureira-Fredes2024-03-121-2/+0
| | | | | | | | | | | The changes related PYSIDE-939 can be removed when 3.9 support is dropped, because the problem was fixed and included in 3.9.13 so we cannot assume everyone will be on that version or superior. Change-Id: I78afc660edc6fbb3bb1a2438e17366e63b24e375 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Add type behavior to SbkObjectTypeFriedemann Kleint2024-01-171-2/+12
| | | | | | | | | | | | | Fill the existing fields and output it in dump(). This saves looking up the type in the type system file when analzying bugs. Query functions might be added later should a need arise. As a drive-by, output the ref count as well. Task-number: PYSIDE-1898 Task-number: PYSIDE-930 Change-Id: Ie5a43d7971dd82e7da1930216041efaccfb324f0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Use PyType_GetSlot() instead of accessing PyTypeObject's slots in library codeFriedemann Kleint2024-01-161-3/+4
| | | | | | | | | | 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>
* PyPySide: Update to Python 3.10Christian Tismer2023-12-211-2/+2
| | | | | | | | | | | | Some newly omitted functions needed support. Some tests should still be fixed in another commit. Task-number: PYSIDE-535 Change-Id: I692417cdcf77373f37538c89b25e591cc4f301a6 Pick-to: 6.6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PEP 697: Use the new type extension provisionChristian Tismer2023-12-071-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | | By Python 3.12, there is now an official way to extend heap types by custom extra data. When we supported PyPy, the old type extension of PySide did no longer work, and we introduced shadow dicts. With the interface found in Python 3.12, we can use direct extended data, again. The supporting structures are not Limited API compatible. We implemented a patch that enables this anyway, but it is valid for this version only without a new review. NOTE: The documentation lists `PyObject_GetTypeData` as Limited API since Version 3.12, but in fact we had to write a cheating patch. [ChangeLog][PySide6] Hidden Type Extensions according to PEP 697 are now used instead of shadow dictionaries. Change-Id: I4b724ba7bcc72470b13f55ea5ebf94666061420d Task-number: PYSIDE-2230 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Shiboken: Fix subtle bug caused by PyPy support and "bug_825"Christian Tismer2023-11-141-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When implementing PyPy support, all Shiboken types lost their hidden extra fields, because they were replaced by shadow dicts. This creates a problem with multiple inheritance. In Python < 3.12, the decision which base type will create the instance is driven simply by the size of the type. In class MetaC(MetaA, MetaB): pass when MetaA is derived from type and MetaB is derived from SbkObjectType, MetaA is not the type that should win. Fixed by simply adding 1 to the default size of PyType_Type. Caused by bug_825 corrected version. The old test is retained as bug_825_old.py . NOTE: This touches a Python 3.8 bug that was fixed in 3.9.12 and 3.10.4 - unfortunately CI Python is older in all cases. Task-number: PYSIDE-2230 Change-Id: I6e82cafb83c8351bbbeafcc80e11d5e45568f73d Pick-to: 6.2 6.5 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* PEP 697: Introduce the SbkObjectType_Check functionChristian Tismer2023-10-251-0/+8
| | | | | | | | | | | | | | | By Python 3.12, there is now an official way to extend heap types by custom extra data. In order to make that most effective, we can no longer accept every type in PepType_SOTP, but keep the types carefully apart. This is done with SbkObjectType_Check, which is very rarely necessary. Change-Id: I9cc4b594f2f676712ba92bf7733c4321b717f252 Pick-to: 6.6 Task-number: PYSIDE-2230 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Unify the structure of type creation functionsChristian Tismer2023-10-251-56/+67
| | | | | | | | | | | | | | | | 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.12, extension bugChristian Tismer2023-10-241-1/+7
| | | | | | | | | | | | | | | | | | | | | | | When SbkTypeFactory._PyType_FromSpecWithBasesHack was written, the intent was to support everything for Python 3.12, although the new function PyType_FromMetaclass cannot be used with the Limited API. The supplied patch did not fix a problem that arises when a type is created without a base class that has the preferred metaclass. In PySide, this happens exactly in the case of SbkObject_type creation. The subtle bug was that metaclass SbkObjectType_Type was reported, but it really was still the old &PyType_Type. The patch fixes that by temporarily changing the type of object. Python 3.12 is the first version that requires that. Change-Id: I4d9d05ed93aa0e1fb297a0b931821ab9cae28ee9 Pick-to: 6.6 6.5 6.2 Task-number: PYSIDE-2230 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* Limited API: update python version usage and fix some minor bugChristian Tismer2023-10-241-4/+4
| | | | | | | | | | | Python versions < 3.8 are gone now and we remove according queries. A basewrapper.c 3.9 query was corrected to use runtime info, instead. This was a potential refcounting but, but had no reported impact. Change-Id: I031aa6af1ce7c0553bada2436b15a04678285f0e Pick-to: 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Get rid of tp_dict in general, amendedChristian Tismer2023-10-111-1/+9
| | | | | | | | | | | | | | | | | | A few more cases of cppgenerator were added. This are now really all cases, because tp_dict is no longer exported. As a very positive side effect, there is no longer direct tp_dict access in the "init_<type>" functions. Usage of PepType_GetDict would have created a permanent extra-reference. NOTE: It was necessary to set SKIP_UNITY_BUILD_INCLUSION on pep384impl.cpp in order to let this work with unity. Change-Id: I021dbc978b51265db96d5d3d438e06aa96230cc1 Pick-to: 6.2 6.5 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Get rid of tp_dict in generalChristian Tismer2023-10-091-1/+2
| | | | | | | | | | | | | | It is a long due task to finally remove the direct access to type object fields. With Python 3.12, direct access to tp_dict became problematic. We use that as a reason to start removing the direct access in favor of function calls. Task-number: PYSIDE-2230 Change-Id: I6f8a7479ab0afdbef14d4661f66c3588f3a578aa Pick-to: 6.2 6.5 6.6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* libshiboken/libpyside: Fix some static analysis warningsFriedemann Kleint2023-09-201-11/+10
| | | | | | | | | | | | - 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 tests sample_privatector sample_privatedtor failing with Python 3.11.5Friedemann Kleint2023-09-201-2/+2
| | | | | | | | | | Remove special characters from the format string as they cause: ValueError PyUnicode_FromFormatV() expects an ASCII-encoded format string, got a non-ASCII byte: 0xc2 Fixes: PYSIDE-2465 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I506efcb44168fdc979a1d16bf33d5d5d14525e2e Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PyPySide: Fix a small, very old glitchChristian Tismer2023-09-061-1/+1
| | | | | | | | | | | | | | | | | | | Many years ago (2012), the format string of SbkObjectType_tp_new contained the string "SO!O!:sbktype". The meaning of this "S" is redundant for historical reasons and means PyObject. It is equal to "O". At some unknown point in time, this "S" was erroneously turned into "s", which means a plain string. Unfortunately, this neat finding does not solve the multiple inheritance problem of PyPy, but this will surely be found at some point, too. Change-Id: I51045216f9c0aa2c9efdda06a2ad5f9ac64e9696 Task-number: PYSIDE-535 Pick-to: 6.5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyEnum: Shortcut old Enum code and generate Python enums directlyChristian Tismer2023-06-301-3/+0
| | | | | | | | | | | | | | | | | The amalgamation of old and new enums is slowly unraveling from the inside. This meanwhile actually removes the old code. Included a change by Friedemann to improve enum value handling. After the signed/unsigned problem was fixed, there was only one case left where Qt and Clang parser disagreed which could be fixed. The final solution uses overloaded functions to generate all necessary cases with minimal footprint in the executable. Task-number: PYSIDE-1735 Change-Id: I3741ce8621e783a750f3c05241c916008f78f39b Done-with: Friedemann.Kleint@qt.io (+2 squashed commits) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Shiboken: Remove an old patch that is no longer necessaryChristian Tismer2023-06-061-10/+14
| | | | | | | | | | | | | | | | | | | | | | | An old refcounting problem from 2019 was fixed by a crude patch to class creation in basewrapper.cpp . This patch now creates an assertion error in debug mode when running the test for issue PYSIDE-2354. The problem was actually a CPython bug and does only exist in Python 3.8 until Python 3.9.12, for all other versions it works fine. See https://github.com/python/cpython/issues/92112 [ChangeLog][shiboken6] An old patch for a Python 3.8-3.9.13 error was timed out and removed from current versions. Task-number: PYSIDE-939 Task-number: PYSIDE-2354 Change-Id: I6c077294dc61491b47b6e75e95fd669144fa0471 Pick-to: 6.5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* cppgenerator: get rid of all goto constructsChristian Tismer2023-03-201-0/+27
| | | | | | | | [ChangeLog][shiboken6] The generated code no longer contains `goto`. Change-Id: I3b90abafd8dbe2c19b4fffb7880322451d1ed068 Fixes: PYSIDE-2256 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Shiboken: Improve an error message by giving more contextChristian Tismer2023-03-101-1/+2
| | | | | | | | | | | "You can't initialize an object twice" was augmented by giving class info. "You can't initialize an PySide6.QtWidgets.QLabel object in class F twice!" Task-number: PYSIDE-1564 Change-Id: Ie243b884caae47f05ec1138cc1c7063b0b477b56 Pick-to: 6.4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* signal: Finally clean up all leaks after complete understandingChristian Tismer2023-02-071-0/+1
| | | | | | | | | | | | | | | | | | | | | The PYSIDE-79 bug was never understood, completely. After getting much more clarity through the work on PYSIDE-2201, the real problem could be found: It turned out that the implementation of descriptors was incomplete. Instead of respecting an already cached instance, it created a new one, all the time, resulting in a serious leak! This became visible by deep inspection of the control flow with VS-Code. After the interaction of PyObject_GetAttr, getHiddenDataFromQObject and signalDescrGet became transparent, the function was completed and the issue finally solved. Fixes: PYSIDE-79 Task-number: PYSIDE-68 Task-number: PYSIDE-2201 Change-Id: Ifd6098b1ce43d9bf51350218deb031bbf9ccb97a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* signature: Evict the __signature__ attribute, long live signature!Christian Tismer2022-12-221-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The __signature__ attribute was used since 2017 with success. With Python 3.10, there was an incompatibility introduced by the rlcompleter module. This was detected quite late, because there is no exception thrown in normal line completion. Using the rlcompleter module directly, the error can be seen. The problem is not the attribute itself, but PySide's need to support *multi-signature*. The signature objects are either regular compatible Signature objects, or in the multi-case, *lists* thereof. Since PyPy was implemented, the internal use of the __signature__ attribute was replaced by a get_signature() call. The attribute was never documented in the public until recently in the developer docs. We therefor can assume that removal of the attribute will cause no problems. [ChangeLog][PySide6] The non-standard __signature__ attribute of functions and classes was removed in favor of get_signature(). No Pick-to because this is meant for 6.5 Change-Id: Iaa8bb08a33db66868d949593e527b753bf989681 Fixes: PYSIDE-2101 Task-number: PYSIDE-510 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Finally implement the __slots__ feature in PySideChristian Tismer2022-10-201-7/+19
| | | | | | | | | | | | | | | | | The __slots__ feature never worked for PySide at all. It was forgotten that __slots__ are implemented as descriptors which are living at the end of the type instance. This was solved for normal SbkObjects and for QApplication as well. Some slight rearrangement of type casts was necessary. [ChangeLog][PySide6] The long missing support for __slots__ was finally added. Change-Id: Ieddb92104ab10e80e564b38e053f280f90d7a6a7 Fixes: PYSIDE-1970 Pick-to: 6.3 6.4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix warnings about unused parameters in codeFriedemann Kleint2022-09-261-1/+1
| | | | | | Pick-to: 6.3 6.2 Change-Id: Ie120284b290d22f2786591955465e0334555e658 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Shiboken: Rewrite the signature initializationChristian Tismer2022-07-071-2/+1
| | | | | | | | | | | | | | | [ChangeLog][shiboken6] The initialization of the signature module was moved into Shiboken and rearranged. This was necessary for the new backward-compatible PyEnum module. This change makes even sense if the PyEnum forgiveness should not work in 3.11 because it is a real cleanup. Change-Id: I5de54584154fb43648617adcac823f42049be57b Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Shiboken: Move the shibokensupport initialization into the moduleChristian Tismer2022-07-071-5/+13
| | | | | | | | | | | | | | | Importing shibokensupport is now possible inside the Shiboken import. That is a prerequisite to re-order the signature initialization, which is again mandatory for the new PyEnum forgiveness feature. This allows to remove much initialization code and makes the Shiboken startup less vulnerable. Task-number: PYSIDE-1735 Change-Id: Iaed4275d7e204fb242b1466cd6d2c09ad10002b5 Pick-to: 6.3 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* libshiboken: Amend error message "not enough arguments"Friedemann Kleint2022-06-151-1/+2
| | | | | | | | | | | In case no arguments at all were passed (assuming they were passed as keyword arguments which only works for optional arguments), add a note about that. Task-number: PYSIDE-1964 Pick-to: 6.3 6.2 Change-Id: Iacaef7604f6127ce6532b31dabba8dd93e45bc78 Reviewed-by: Christian Tismer <tismer@stackless.com>
* libshiboken: Fix a crash in Shiboken::Object::isValid() for Python 3.11Friedemann Kleint2022-06-101-0/+1
| | | | | | | | | | | | | | | | The function is passed type objects for class methods, which caused it to crash. The first clause did not catch this, and so it was cast to SbkObject below. Add a type check to prevent this. Pick-to: 6.3 6.2 5.15 Task-number: PYSIDE-1960 Change-Id: Icfdd6fefb7156ac5961444bd5395109849a1d66e Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix deprecation of the Py_TRASHCAN_SAFE_BEGIN/END macrosFriedemann Kleint2022-06-101-0/+8
| | | | | | | | | | Replace by Py_TRASHCAN_BEGIN/END as introduced in 3.10. Pick-to: 6.3 6.2 5.15 Task-number: PYSIDE-1960 Change-Id: I17aaa2e9fa9c44f8c1004fc8dba8b22932ea44d0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@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>
* Python 3.10: Fix GIL state crash when collecting QObjects with signalsFriedemann Kleint2022-05-061-1/+4
| | | | | | | | | | | | | | | SignalManager::retrieveMetaObject() calls SbkObject_GetDict_NoRef() to obtain the ob_dict. This function creates the dict if it does not exist, causing a GIL violation in some situations (when calling from some ~QObject from Qt). Acquire the GIL for the creation. A proper fix might be to add a function that does not enforce the creation of the dict from SignalManager::retrieveMetaObject(). Pick-to: 6.3 6.2 Fixes: PYSIDE-1919 Change-Id: I3f5f37c4ca92b368763c0dc2a43f16efa004de06 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix uninitialized variable causing crash when using shiboken.deleteLuc Touraille2022-04-091-0/+1
| | | | | | | | | The isQAppSingleton flag was not initialized, meaning that any shiboken wrapper could be randomly considered as a QCoreApp one. Pick-to: 6.2 5.15 Change-Id: I96c836762a2ad2a6e8978dee10965c086bd50645 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Add a function to check argument countsFriedemann Kleint2022-04-061-0/+16
| | | | | | | | | This reduces the generated code. Task-number: PYSIDE-661 Change-Id: I4d06fd9223a8e87fbe3a7e2d8c6a482e56a10cf5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide: Leave the underscore variable alone in QApplicationChristian Tismer2022-02-081-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | QApplication has special treatment through the extra rules of only one QApplication instance may exist. To ensure this, different approaches were used. The first attempt was using refcounts and made sure that "del qApp" really destroys the QApplication instance. This did not work in interactive mode because the automatic underscore variable creates cycles. As a simple workaround, we assigned None to underscore when a QApplication was created. When moving to the new concept of an explicit shutdown() call, this assignment was forgotten to remove. [ChangeLog][PySide6] A left-over replacement of the interactive underscore variable when QApplication is created was removed. Change-Id: I78f3e3714531d599c4b5b76f956b1d631014ad94 Pick-to: 6.2 Fixes: PYSIDE-1758 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyPySide: Fix a build error due to an ABI misuseChristian Tismer2022-02-031-1/+2
| | | | | | | | | PyPy has a different layout of PyVarObject. Avoid using that by a type cast. Task-number: PYSIDE-535 Change-Id: Iff0dab0be4b758ffac8115f5e5460992662cc4b0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyPySide: Rename interface functions and classes to simplify debuggingChristian Tismer2022-02-031-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add a debug operator for SbkObjectFriedemann Kleint2022-02-021-5/+43
| | | | | | | | | | | | | | Similar to the existing operators for Py(Type)Object, add a debug operator for SbkObject. Split the existing helpers such that the PyObject information can also be printed. The operator prints the information Qt-syle, more concise than Shiboken::Object::info() without invoking str() and side effects. Task-number: PYSIDE-1709 Pick-to: 6.2 Change-Id: If18157416f27a8ff188da4140701665bebffb927 Reviewed-by: Christian Tismer <tismer@stackless.com>
* PyPySide: Do some cleanup and ImprovementsChristian Tismer2022-01-051-8/+4
| | | | | | | | | | | | | For more clarity, the function SbkObject_GetDict is renamed to SbkObject_GetDict_NoRef. The internal __dict__ implementation SbkObjectGetDict is re-written to use SbkObject_GetDict_NoRef, which is more correct because of PyPy's tp_dict handling. Task-number: PYSIDE-535 Change-Id: I28034d9199918859de809fde08c413b4b66a3136 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>