aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken
Commit message (Collapse)AuthorAgeFilesLines
* Fix qApp macro refcountCristian Maureira-Fredes2018-03-211-1/+6
| | | | | | | | | | | | | | | There are two borrowed references in the code, so we need to manually increase the refcount. Usually the PyEval_GetBuiltins and PyModule_GetDict functions are used locally, so there is no real need of taking care of the refcounts, but since we are using it globally, and adjusting the refcount by ourselves, it was necessary to add the missing references by hand. Task-number: PYSIDE-585 Change-Id: Icc1e7719a6b5d3654d12ab37cd509a096821d7a6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Type system: Add attribute indicating C++ 11 enum classesFriedemann Kleint2018-02-282-4/+11
| | | | | | | | | | | | | Introduce enumeration for the type to EnumTypeEntry which can be specified by the boolean "class" attribute. For the enum classes, the value names need to be qualified by the enum name to match the C++ API. For the C++ generator, add an overload to Shiboken::createScopedEnumItem() that takes a PyTypeObject and add the enum items to the enum so that the name is in the enum scope. Change-Id: Ia0e469d13b08c196b9ddd965b9cf3cc62a38630b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2018-02-231-1/+1
|\ | | | | | | Change-Id: I5d1a4734e8f44785898ba62beaa0bdd2004fca22
| * Don't copy duplicate libraries on package installationAlexandru Croitor2018-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes sure to resolve symlinks and copy only one file for every dynamic shared library used (vs 3 before -> 2 symlinks + 1 actual library). This avoids duplicate files, as well as saves space when creating wheel (e.g. no 3 copies of standalone WebEngine library). This filtering happens copying from CMake install dir into pyside_package_dir (the symlinks are still present in the CMake dir, but that shouldn't harm anybody, and might be useful for users of shiboken only for example). Task-number: PYSIDE-495 Change-Id: I0fe454e16c6b254a8682aa7b1c702ec01a3064f0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2018-02-021-0/+2
|\| | | | | | | Change-Id: I777970f7bb17db766660d82556559eadd7293355
| * Fix signature extension disablingChristian Tismer2018-02-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signature extension is a feature that can switch itself off, using the expression PY_VERSION_HEX >= 0x03040000 || \ (PY_VERSION_HEX < 0x03000000 && PY_VERSION_HEX >= 0x02070000) Unfortunately, the use of this constant when disabled became inconsistent over time. This patch corrects that and also adds a cosmetic improvement that was lost. Task-number: PYSIDE-510 Change-Id: Id1653c391d921a2c51008db2bc222d6f4bec9e90 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | libshiboken: Code cleanupFriedemann Kleint2018-01-272-47/+0
| | | | | | | | | | | | | | | | Remove apparently unused/deprecated code. Change-Id: I566014bafdcbf0b3b46e9dc836c451c64d409511 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Prevent infinite loop due to bad __getitem__ implCristian Maureira-Fredes2018-01-151-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Looking at PYSIDE-441 there was an issue regarding overloading the __getitem__ method on a class that inherits from QObject. The bug report showed that setting an object of the same class to be the parent of another object of the same class ended up causing an infinite loop when trying to get the parent element. Overloading __getitem__ implicitly converts the class into an iterator, and the developer *must* include a proper implementation of the method which raises a StopIteration exception when needed. Commonly, people that overload this method included access to class data structures where in most of the cases an IndexError is raised which forces the iteration to stop. Since the bug report did not include this code and also there was no access to any internal variable, no exception was raised and ended up causing an infinite loop. This can be replicated in python as folows: class A(object): def __getitem__(self, arg=None): print("getitem called:", arg) #raise StopIteration a = A() print(list(a)) This small fix avoids the infinite loop when the method __len__ is not implemented (length = -1) or when the length of the pyObj is zero. Without a proper implementation of __getitem__ (Raising IndexError or StopIteration) the infinite loop will happen. If __len__ is not implemented, then the application will complain, but does not matter since this is never checked during the iteration. Change-Id: I74e7bf1755c265dbc309bb6c5a760f11643fd7ed Task-number: PYSIDE-441 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | libshiboken: Recover from numpy import failuresFriedemann Kleint2017-12-211-3/+3
| | | | | | | | | | | | | | | | | | | | Clear the Python error on failure. Note that PyErr_Occurred() is not set for some reason in that case. Task-number: PYSIDE-580 Change-Id: I5672b9f5bf98e3d409abb4132f2face060826a0a Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-11-271-0/+32
|\| | | | | | | Change-Id: I79637555fbfbd596dee4313baf80149d03bb5206
| * Investigate the sporadic segfaults on RHELChristian Tismer2017-11-231-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lately, the RHEL platform tends to segfault between 0-4 times in a test run. I suspect that is related to some finalization code that is triggered at a special time, due to a stressy situation. But we don't know until we ask the CI system by printing a stack trace. This patch prints a stack dump after a segfault happened. The dump is only activated when the environment setting QTEST_ENVIRONMENT=ci is true. (The above needs to be compared with strcmp or strstr) Note that the tests _are not isolated_. I recognized that by the warnings module that leaked between tests. The processes are shared, unless you have setup and teardown functions. There might for instance be some hidden refcount bug that triggers only early enough in a stress situation. Change-Id: Ibbc592e7bdcbdd3cdbc06f203be3e5fc1daaf774 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-11-131-1/+1
|\| | | | | | | Change-Id: Ib0f638130d21a5619f239a9fb8beb7d92ad8d0e8
| * voidptr.cpp: Assign bool directlyFriedemann Kleint2017-11-071-1/+1
| | | | | | | | | | | | | | | | Fix MVC warning: voidptr.cpp(90): warning C4804: '>': unsafe use of type 'bool' in operation Change-Id: I690becd76320d843e79a56ea792b65fa4cc9a498 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-11-0614-1130/+565
|\| | | | | | | Change-Id: I72583df407fc5b3caa8bf35fd997889a4ac86512
| * Implement proper void pointer (void*) supportAlexandru Croitor2017-11-066-26/+524
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change introduces a new type into the shiboken2 module which is imported by calling "import PySide2.support.VoidPtr". The type takes care of conversions from / to void* values in function signatures. Creating an instance can be done by passing either a shiboken wrapped object, or an integer representing an address, or a python object that implements the buffer interface. For example, this is useful for passing numpy arrays to C OpenGL functions that take void* parameters. First you convert the array into a bytestring (using numpy.array.tobytes(), then you instantiate a VoidPtr from that bytestring, and finally you pass it along to a GL function. One corner case that is currently not supported is void** parameters. Change-Id: I01e291d6856cb6bd8b5175adc3ead6b728036535 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * Remove dead / unused code regarding conversionsAlexandru Croitor2017-11-0212-1105/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a lot of code that was previously used for doing conversions between C++ / Python types (apparently relying on extensive RTTI / typeid manipulations), which got superseded by a cleaner templated approach. The old code was left behind, and there were a few instances where it was still used even though it wasn't needed, like in QtScript typesystem XML and shiboken's enum handling. Remove the old code, apply the small changes needed to make it work with new the code. This is cleanup to reduce the confusion regarding conversion behavior, and also preparation for a proper implementation of handling "void*" types. Change-Id: I8f16bb31436f9a677bb2d64c7197c4375005b656 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-10-277-10/+289
|\| | | | | | | Change-Id: I94cb5a7dab97cff3591bac534228bfd3e3ad5938
| * Support the qApp macro correctly, final version incl. debugChristian Tismer2017-10-275-5/+283
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For short the new features: - there is a qApp in QtCore, QtGui and QtWidgets for compatibility, and also in __builtins__ for a true macro-like experience. - if you delete any qApp variable, the Q*Application is reset and you can start over. Long description: There is a qApp macro in Qt5 which is equivalent to Q*Application.instance() . Python does not have macros. Both PyQt5 and PySide2 have an according structure in QtWidgets. In the case of PySide2, the qApp variable is first initialized to None and later to QApplication(). This does not reflect the original sense of the qApp macro, because - it only handles QApplication, - it does not handle destruction. This "macro" should live in QtCore, but both PyQt5 and PySide2 decided to put this in QtWidgets. As a compromize, I propose to put qApp into all three modules, and into __builtins__ as well, so wherever you create an application, you find this "macro" in place. While changing the code, I stumbled over the template set_qapp_parent_for_orphan. I tried to make sense out of it and finally removed it. There were no side effects but bug PYSIDE-85 is gone, now. With some extra effort, I created a singleton qApp that changes itself. This way, a true macro was simulated. Note that this was not possible with a garbage collected variable, and I had to make shiboken aware of this. As the final optimization, I turned qApp also into a fuse variable: Delete any qApp variable and Q*Application will finish when there is no extra reference. Task-number: PYSIDE-85 Task-number: PYSIDE-571 Change-Id: I7a56b19858f63349c98b95778759a6a6de856938 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * Fix the signature of the Q*Application constructorChristian Tismer2017-09-292-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Q*Application had PySequence as Parameter, although only QStringList is accepted. That resulted in an implausible error message when a list of, say, Integers was given. This patch - replaces PySequence by QStringList (one more tuple layer), - fixes QCoreApplication to give the same kind of error messages, - renames the shiboken function sequenceToArgcArgv to listToArgcArgv and changes it to only allow list descendents. We also changed signature.typing in one line to display List[str] correctly. I think this belongs more to PySide-331, a fixed qApp. Task-number: PYSIDE-510 Task-number: PYSIDE-331 Change-Id: Ib256c6a2db05a3db826454e1bf1b4729d59a240b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Signature: Remove pre 5.7 parts, fix coding styleFriedemann Kleint2017-09-291-1/+1
| | | | | | | | | | | | | | | | Complements 30a1c9c41e5e6d4166f171b9477c6f46cafa782f. Task-number: PYSIDE-510 Change-Id: I76e433dc35dbe88dbf254b19b82b8c392af0dad4 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-09-285-6/+726
|\| | | | | | | Change-Id: I47521e21977b1f17fcc65590f565270b2440a48b
| * Signature: buglet makes clang complainChristian Tismer2017-09-251-1/+1
| | | | | | | | | | | | | | Some small oversight is now an error after the last clang update. Change-Id: I61b118d772cacdf7950e3b43e76cc4351c3062f3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
| * Signature: fix documentationChristian Tismer2017-09-251-1/+4
| | | | | | | | | | | | | | | | There was some glitch that made a few sentences incomplete. Task-number: PYSIDE-510 Change-Id: Idd11c7a0d9f31aab4ab80e6fd6002f2320695ad5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
| * Implement introspection with __signature__ packageChristian Tismer2017-09-205-6/+723
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signature module was turned into a package under 'PySide2/support/signature'. The package is completely isolated so that nothing is leaking into the normal import machinery. The package is also not initialized unless a __signature__ attribute is accessed. The only change to Python during a PySide run is the existence of the __signature__ attribute. As a side effect, all tests run at the same speed as before this extension. The module does not actively import PySide modules. Instead, it inspects sys.modules and reloads its mapping.py if needed. Example usage: >>> PySide2.QtWidgets.QGraphicsAnchorLayout.addAnchors.__signature__ >>> PySide2.QtWidgets.QGraphicsAnchorLayout.__signature__ The module has been thoroughly tested on macOS. I consider this ready. Task-number: PYSIDE-510 Change-Id: Ibb231a7fbb4ccc1a7249df55e3881a4e21a19c0d Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Add numpy supportFriedemann Kleint2017-08-033-3/+346
| | | | | | | | | | | | | | | | | | Add simple array converters giving access to NumPy arrays. Task-number: PYSIDE-354 Task-number: PYSIDE-516 Change-Id: I2446b0f1ef98eaf12df95e4bd0e03d73e0cd7126 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | libshiboken: Add Array convertersFriedemann Kleint2017-08-038-1/+547
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a SbkArrayConverter struct which provides a list of check functions that return a converter function for an array of matching size. Add simple array converters for arrays of C++ primitive types. Instances of the ArrayHandle<>, Array2Handle<> templates will be generated which may point to internal data or allocated arrays. Task-number: PYSIDE-354 Task-number: PYSIDE-516 Change-Id: I157606891fad345ccd7af6d4a9d4dcb0c634b2f4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-07-141-1/+1
|\| | | | | | | Change-Id: I1dd2958b252b82e8699e8d2212afdce0086a16d2
| * Improve suffix names for shared libraries and cmake config filesAlexandru Croitor2017-07-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change decouples the naming of general shared libraries, python module extensions, and cmake configuration files. All of them are now computed depending on the python version and python build configuration, and can also be manually set via CMake variables. The module extensions names now use the most detailed 'import' prefix, which usually informs whether a debug or release python was used, or the Python ABI flags (for Python >= 3.2). When a debug Python interpreter is used for building PySide2, the preprocessor define Py_Debug is now correctly propagated to PySide2 sources, which fixes previous crashes in debug builds. This affects only Linux and macOS builds. There is a subsequent change for making it work for Windows builds. All in all, this now allows proper mixing of debug / release versions of the Python interpreter with debug / release versions of PySide2 on Linux and macOS. Task-number: PYSIDE-508 Change-Id: I88a05c3ada0fb32c7c29bdb86d7a2c15acc963b8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Shiboken: Set C++ 11 globallyFriedemann Kleint2017-06-281-1/+0
| | | | | | | | | | Change-Id: I17634ebc245cae87819af16d79704326905e5783 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | [Reland] Fix crash on exit with debug Python 3Alexandru Croitor2017-06-271-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | Crash happens because of an use-after-free error. This is a bandaid fix transforming the crash into a memory leak. Proper fix will require more investigation and time. The commit was missing in 5.9 branch after repo merge. Task-number: PYSIDE-488 Change-Id: I56358573ca60d6f18fd85fbd7eb3eb0da8fbf163 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.6' into 5.9Friedemann Kleint2017-06-096-9/+18
|\| | | | | | | Change-Id: I73f39966a2af7aa935e1890e29c9b71573aae97c
| * libshiboken: Fix/Silence some MSVC warningsFriedemann Kleint2017-06-096-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | autodecref.h(110): warning C4522: 'Shiboken::AutoDecRef': multiple assignment operators specified autodecref.h(78): warning C4800: 'PyObject *const ': forcing value to bool 'true' or 'false' (performance warning) conversions.h(282): warning C4800: 'long': forcing value to bool 'true' or 'false' (performance warning) basewrapper.cpp(625): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) basewrapper.cpp(654): warning C4800: 'SpecialCastFunction': forcing value to bool 'true' or 'false' (performance warning) basewrapper.cpp(1014): warning C4800: 'Shiboken::ParentInfo *': forcing value to bool 'true' or 'false' (performance warning) basewrapper.cpp(1044): warning C4800: 'void *': forcing value to bool 'true' or 'false' (performance warning) helper.cpp(56): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data shibokenbuffer.cpp(46): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning) Change-Id: If1517fde8e7670f258a56f6d845a66ebb3d82141 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * move everying into sources/shiboken2Oswald Buddenhagen2017-05-2237-0/+8562
| | | | | | in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it.
* move everying into sources/shiboken2 (5.9 edition)Oswald Buddenhagen2017-05-2237-0/+8528
in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it.