aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix booleans and empty list cases in QSettings5.12Cristián Maureira-Fredes2020-06-121-3/+43
| | | | | | | | | | | | | | | | | | | | | | | After the fix for PYSIDE-1010 there were two things that were not properly understood: 1. A special case for booleans was required, 2. When a list was detected, the split was wrongly creating a list with a '0' instead of an empty one. Additonally, due to the wrong treatment we couldn't notice if the value 0 was None, the number zero, or even false, so this patch amends the previous implementation to properly treat these cases. New test cases were added. Change-Id: I41d5387bb835cfa96f94e5577e993a4b87b303f0 Fixes: PYSIDE-1130 Fixes: PYSIDE-820 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit ba04613a65be7b50bbcc9dae8c18d195243513c3) Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Improve the libdir for windowsCristián Maureira-Fredes2020-02-271-1/+8
| | | | | | | | | | | | | | | | | | | | With virtualenv 20 we have the case where the first path in the PYTHON_LIBRARIES cmake variable was wrong: a_virtual_env/libs/python3.lib so the python code inside the helper didn't have a proper check if the file was valid or it was just a wrong construct. Additionally, the 'prefix' variable will contain the virtual environment directory location, which will not contain the 'libs' directory, because that's included in the system's installation path. To solve this, we use the 'INCLUDEPY' directory, which is correct as a base to create the real 'libs' one. Task-number: PYSIDE-1231 Change-Id: Ifca08d74c49cd57572836a087edb96c089266dc7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 22e359bc19daf19033332aa2d7bb9726c7f4be14) Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Change QtQml tests file permissions to 644Cristián Maureira-Fredes2019-07-1734-0/+0
| | | | | Change-Id: I0447da5e1ace3f6acc930aa4296576ec447f1be5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add optional support for types in QSettings::valueCristián Maureira-Fredes2019-07-173-0/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This add an optional named parameter to the function value() to automatically cast the type that is being returned by the function. An example of this situation could be an ini file that contains the value of a one-element list: settings.setValue('var', ['a']) The the ini file will be: [General] var=a # we cannot know that this is a list! Once we read it, we could specify if we want the default behavior, a str, or to cast the output to a list. settings.value('var') # Will get "a" settings.value('var', type=list) # Will get ["a"] The cppgenerator was modified to add a verification step before trying to get the named parameter, since it could be optional and having one named parameter was assumming that all of them were provided. Change-Id: I8f379debea86b42cf89019d432e990084c9e6614 Fixes: PYSIDE-1010 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add support for parameterNames in SignalsCristian Maureira-Fredes2019-07-043-0/+127
| | | | | | | | | | | | | | | | | | | | | | There were many uses cases when a proper interaction between Python and Qml was needed, one of them was the case to emit signals from Python an get those values via an argument name in QML. A simple example describing this situation can be found in PYSIDE-634: Python: sumResult = Signal(int, arguments=["sum"]) sumResult.emit(42) Qml: onSumResult: console.log(sum) // will print 42 A test case based on the same example was added. Change-Id: I0908f97d88eaadc0c02d81bc4daca936f72f6c6a Fixes: PYSIDE-634 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Cleanup pointer and trailing whitespace (omissions)Christian Tismer2019-06-2516-46/+46
| | | | | | | | | | | | | | | | | The "Cleanup pointer whitespace" patch was augmented by some C++11 changes. Unfortunately, this was done in the same commit, and so some old whitespace that was removed could re-appear invisibly, since it was in the original version. This fix tries to remove all trailing whitespace and also adds a few " *" corrections that were lost. The "type *" entries in XML files were changed back to "type*". Change-Id: Ic5c945ad64a47455fb15eebdf184b126af5ecd1d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Cleanup pointer whitespace everywhereChristian Tismer2019-06-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Support the qApp macro in "scriptable application"Christian Tismer2019-06-171-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed from "Fix scriptable application to support the qApp macro" because qApp was improved instead of scriptable application. The qApp macro needed some extra effort to support the qApp "macro" which is only defined in the Python wrappers. I took some generated code, created a QApplication instance in Python and used then reduced generated code to get at the object and adjust the refcount. This solution was then rejected, because I can do better, and in fact, scriptable application now has a correct qApp macro too, without any change to scriptable application. The central idea was to look into the module init function at import time and to see if a Q*Application already exists. I was not aware of that import. Many thanks for the rejection! :-) Update.. -------- After many attempts to make the qApp variable correctly behave like always, I recognized that pre-existing Q*Application instances have no wrappers or constructors at all! With that, it is not possible to create a sophisticated qApp macro as a singleton variable in the desired way. Fortunately, this is also not necessary, because a C++ Q*Application cannot be deleted from Python, and there is no point in supporting more that a simple variable. So in case of a pre-existing instance, the qApp variable now gets redirected to that instance. A small test was added to application_test.py that is triggered by an import. A weird effect when "qApp" was typed interactively before calling "QApplication()" was fixed, too. Change-Id: Ic69dd6a21c964838a90f63e316d299b62a54d612 Fixes: PYSIDE-571 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide: Allow any existing attribute in the constructorChristian Tismer2019-06-042-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are signals and properties which are correctly supported in PySide by the function "fillQtProperties". The structures are introspected by calling "QMetaObject::indexOfSignal" and "QMetaObject::indexOfProperty". By allowing any property, extending the above restriction, we break the Qt API slightly, but have the tremendous advantage of being able to write all needed properties into the constructor call. This approach is a compromize that keeps the attribute calls as they currently are. Supporting real properties where we actually have getter and setter functions would be possible as well, but that would break compatibility very much! It has to be discussed if we want to support a configuration switch that enables this incompatible change. If we would go this far, then I would do this together with changing mixedCase to lower_case. A simple test case has been added. Task-number: PYSIDE-1019 Change-Id: I8094df51d63aa767a5a9ec1c83bcf7db7b157a01 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* correct bool(qApp) on Python 2Christian Tismer2019-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The idiom to create an application if none exists qApp or QApplication() did not work on Python 2. This was recognized when another unrelated test broke that tried to use the idiom. This patch adds the missing method to Py_TYPE(Py_None) which Python 3 already has. A test case was added. Side-effect.. The warning about missing braces is gone, after the "PYTHON_IS_PYTHON3" macro is defined. This was forgotten in the review when when the macro was moved out of signature.cpp . Task-number: PYSIDE-571 Change-Id: I9b9304f407cd4cafb3ba0945ffb045802503a343 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Implement the Buffer Protocol on VoidPtrRenaud Aubin2019-06-051-1/+6
| | | | | | | | | | Some use cases need direct data access for performance, e.g. initializing QPolygonF data with numpy.frombuffer. Implementing the Buffer Protocol as described in PEP3118 will allow direct data access. Change-Id: I13c46055b1cba115d099f1becb64c4cd04acdf0e Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Make it possible to extend namespacesFriedemann Kleint2019-05-222-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt has some modules, where functions and classes are added to namespaces of other modules. For example, QtGui adds the free functions mightBeRichText() and convertFromPlainText() to the "Qt" namespace and Qt3DQuick adds a namespace "Quick" to the namespace "Qt3DCore" started in Qt3DCore. Shiboken was unable to handle this since the name of the index constant was derived from the namespace name and would thus clash. Also, all code model items from the base module would be re-generated into the extended namespace. To fix this: - No longer join namespace code model items in clang builder. - Search for pre-existing namespaces in traverseNamespace() before creating a new one, continuing populating it. - Add a "files" attribute taking a regular expression to match header names to the namespace type entry, making it possible to restrict code model items by files when extending namespaces (as otherwise, all base items are again added). - Add "extends" attribute specifying the package name of the namespace to extend, which will be used as base type in CPython. - Disambiguate the SBK indexes of namespaces and the init_ functions by adding the module name. Change-Id: Ib552e878911942fa4d52d2bb0c6695e5b2c4c341 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add PySide2: Add OpenGL version functions as separate moduleFriedemann Kleint2019-05-021-0/+1
| | | | | | | | | The OpenGL version functions produce a lot of library code, so, add them as a separate module. Task-number: PYSIDE-955 Change-Id: I44737f4741f0a81f46a192961173e154ae66698e Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix warnings about signatures 'setUniformValue(const char*,...)' not being foundFriedemann Kleint2019-04-264-4/+12
| | | | | | | | | | | | | | | | | | | Use a regular expression with the types, fixing: qt.shiboken: (gui) signature 'setUniformValue(const char*,GLfloat)' (specified as 'setUniformValue(const char*, GLfloat)') for function modification in 'QOpenGLShaderProgram' not found. Possible candidates: ... setUniformValue(const char*,float,float,float,float) in QOpenGLShaderProgram setUniformValue(const char*,int) in QOpenGLShaderProgram setUniformValue(const char*,uint) in QOpenGLShaderProgram ... Amends 05ae61cba5f943eb58343b44f8d474bc88bf0ce4 Task-number: PYSIDE-989 Change-Id: Ib12ca0309dfa46cca87e8deb546378b185a56b66 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Declare XML files to be in encoding UTF-8Friedemann Kleint2019-04-181-1/+1
| | | | | | | | Some XML tools trip over the missing character set. Change-Id: Icbe1b2485325b70c4772b6a370a98fd529437a8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Improve the Selftest in the RegistryChristian Tismer2019-03-252-35/+101
| | | | | | | | | | | | | | The registry had a duplication of code in the self-test that led to an oversight. To prevent that in the future, the error handling has been rewritten, and an extended self-test was written that checks the correctness of every case. A truth table has beed added as a reference for questions. Change-Id: I4570b2388c9b179b33c9520a484e09b9ccb68918 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Implement Embedding To Make Signatures Always AvailableChristian Tismer2019-03-203-2/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Situation.. PySide works fine with normal applications. But when installers are used to pack the application together, then the signature extension cannot be loaded. This is a problem that exists since the signature extension was written. But starting with PySide 5.12.1, the signature extension is very visible, because it is used to support the __doc__ attribute. There have beed successful attempts to solve the problem for PyInstaller and Py2App. But there are more packers available, and they all need a change both in PySide and in the packer. Solution.. To solve this problem once and for all, we embed the Python support files in the binary shiboken package. When the Python files are not normally accessible, they are unpacked from a ZIP file. Details.. - The embedded files shall only be used when the normal files are not available, - The signature extension should no longer be lazily loaded. When the application starts, all files should be present. - We drop support for shiboken2.support.signature and use a single, independen folder 'shibokensupport' (proposal). This avoids problems with multiple existence of the shiboken2 folder. PySide2.support.signature remains the official interface, but it's only an alias when PySide2 exists. - The embedding is used when the normal files cannot be loaded for some reason. It can be enforced by a sys variable "pyside_uses_embedding". - Testcase is included. - Tested with PyInstaller on macOS Fixes: PYSIDE-932 Fixes: PYSIDE-942 Change-Id: Iaa62dc0623503a2e0943eedd10d2b2484c65cc2d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Simplify Python Imports For EmbeddingChristian Tismer2019-03-202-2/+2
| | | | | | | | | | | | | | | | | | | | | | After the project split, shiboken exposed its own modules, and the overall structure with shiboken2.support.signature and PySide2.support.signature was already quite complicated. When introducing embedding, it is necessary to have some support folder that gets unpacked from a zipfile. That means, the shiboken2 root directory would be in the zip file in the embedding case. This does not only increase the complexity, it further means that we must make shiboken2.so available in the shiboken2 containing zipfile! In order to avoid that, we stop the dependency from the two support directories and use shibokensupport, instead. The simplification of the loader and other modules is also significant. Task-number: PYSIDE-510 Change-Id: Ic735a8d36f10f03698378f2ac9685a5955e40b0c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add toBytes() and BufferProtocolCristian Maureira-Fredes2019-03-151-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | VoidPtr: Add toBytes() method that return a char* representation of the void* pointer. QByteArray: The current implementation only provided the Buffer Protocol for Python2, this patch includes the getbuffer implementation for Python3. Having a BufferProtocol implementation for Python3 allows the initialization of VoidPtr to get access to the internal content, so one can go back and forward with the representation of it: ba = QByteArray(b"Hello World") vp = VoidPtr(ba, ba.size()) vp.toBytes() # b"Hello World" The BufferProtocol was also changed for Python2 including the new buffer protocol (Py_TPFLAGS_HAVE_NEWBUFFER) function `bf_getbuffer`. A test case was included. Fixes: PYSIDE-934 Change-Id: I8936966da91b2dcc879c582cfc35e6a35f7a60b6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Amend The Python 3.5 FixChristian Tismer2019-03-011-5/+1
| | | | | | | | | | | | After the bug found in PYSIDE-928, the contextlib problem of Python 3.5 also vanished. What remains is the crash on shutdown which is caused by module 'testbinding'. Task-number: PYSIDE-953 Change-Id: I07f18fa468fdb0758ee4e4b7663c3a42bec42822 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Prevent Python 3.5 From Crashing The BuildChristian Tismer2019-02-261-1/+5
| | | | | | | | | | | | | | | | | | | Python 3.5 has a bug that crashes the build. See the description in the issue tracker. The cure is to use a more recent contextlib.py and to avoid a PySide cleanup function that creates the crash. The problem is not solved for Python 3.5, and it is not clear if the testbinding module has a hidden bug, too. But this fix seems to be good enough for the moment. We should decide if we are going to fix Python 3.5 or abandon it altogether. Change-Id: Iacf2237de1f34d2b3cd1d68f1fb5833bdca3fdc2 Fixes: PYSIDE-953 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix Shiboken.ObjectType.__new__ for Python 2.7Christian Tismer2019-02-071-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | type(QtWidgets.QWidget).__new__(type(QtWidgets.QWidget), "", (), {}) gave a problem in Python 2.7 after transition to PEP 384. The reason for the problem is a check in Python 2.7 that tries to find out if the function used to create a new object is a secure (builtin) one. Therefore, all new types that are generated by a Python function are filtered out. Unfortunately, Python 2.7 did that assuming that only Python classes are heap types. This is at least no longer true since Python 3 migrated to the new type API where all new types are heap types. The internal check was therefore changed to do the test for a builtin "new" function differently. But not in Python 2.7 . The workaround was to create the Shiboken.ObjectType as a heap type and then remove that flag from the type. This seems to have no bad effects, probably because the types did barely change when doing the transition. Anyway, I will stay tuned and watch out if this later creates a problem. Task-number: PYSIDE-816 Change-Id: Ia596716b0e5dff3f1a7155ab6765186ef0b9d179 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Modernize cmake buildAlexandru Croitor2019-02-073-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a CMake super project that includes the shiboken2, PySide2 and pyside2-tools subprojects, so that it's possible to build everything from Qt Creator (or any other IDE that supports CMake) with minimal set up effort, and thus inform the IDE CMake integration of all relevant files, for easier code editing, navigation and refactoring. This also lays the foundation for allowing 3rd parties to use the shiboken2 generator to generate custom modules. This is achieved by eliminating various hardcoded paths for libraries and include directories. Start using CMake targets throughout the build code to correctly propagate link flags and include dirs for libshiboken and shiboken2 executable targets. Same for the libpyside target. Generate two separate cmake config files (build-tree / install-tree) that can be used with find_package(Shiboken2), to make sure that the PySide2 project can be built as part of the super project build. This is currently the only way I've found to allow the super build to work. Note that for the build-tree find_package() to work, the CMAKE_MODULE_PATH has to be adjusted in the super project file. The generated config files contain variables and logic that allow usage of the installed shiboken package in downstream projects (PySide2). This involves things like getting the includes and libraries for the currently found python interpreter, the shiboken build type (release or debug), was shiboken built with limited api support, etc. Generate 2 separate (build-tree and install-tree) config files for PySide2, similar to how it's done for the shiboken case, for pyside2-tools to build correctly. Install shiboken2 target files using install(EXPORT) to allow building PySide2 with an installed Shiboken2 package (as opposed to one that is built as part of the super project). Same with PySide2 targets for pyside2-tools subproject. Make sure not to redefine uninstall targets if they are already defined. Add a --shorter-paths setup.py option, which would be used by the Windows CI, to circumvent creating paths that are too long, and thus avoiding build issues. Output the build characteristics / classifiers into the generated build_history/YYYY-MM-DD_AAAAAA/build_dir.txt file, so it can be used by the test runner to properly filter out blacklisted tests. This was necessary due to the shorter paths options. Fix various issues regarding target includes and library dependencies. Remove certain duplicated cmake code (like limited api check and build type checks) in PySide2, given that that information will now be present in the exported shiboken2 config file. Include a short README.cmake.md file that describes how to build the super project. References used https://rix0r.nl/blog/2015/08/13/cmake-guide/ https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/ https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1 https://cliutils.gitlab.io/modern-cmake/chapters/basics/functions.html https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html https://github.com/ComicSansMS/libstratcom/blob/master/CMakeLists.txt Abandoned approach using ExternalProject references: https://cmake.org/cmake/help/latest/module/ExternalProject.html https://stackoverflow.com/questions/44990964/how-to-perform-cmakefind-package-at-build-stage-only Fixes: PYSIDE-919 Change-Id: Iaa15d20b279a04c5e16ce2795d03f912bc44a389 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* typesystem_gui_common.xml: CleanupFriedemann Kleint2019-02-064-36/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove duplicate modifications of QOpenGLExtraFunctions::SamplerParameteri/fv() that are covered by the below regular expression - Remove QMatrix4x2::copyDataTo() as is done for the other QMatrix<N>x<M> classes, fixing: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'float *' of argument 1 in function 'QMatrix4x2::copyDataTo(float * values) const'. - Remove the array modifications of the QMatrix<N>x<M> constructors (specializations of QGenericMatrix). They don't work since the handling is not implemented in shiboken's AbstractMetaBuilderPrivate::inheritTemplate(). This can be fixed, but has no effect here since the manually added constructor from a PySequence always takes preference. This fixes: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const float *' of argument 1 in function 'QMatrix2x2::QMatrix2x2(const float * values)'. 'const float *' of argument 1 in function 'QMatrix2x3::QMatrix2x3(const float * values)'. 'const float *' of argument 1 in function 'QMatrix2x4::QMatrix2x4(const float * values)'. 'const float *' of argument 1 in function 'QMatrix3x2::QMatrix3x2(const float * values)'. 'const float *' of argument 1 in function 'QMatrix3x3::QMatrix3x3(const float * values)'. 'const float *' of argument 1 in function 'QMatrix3x4::QMatrix3x4(const float * values)'. 'const float *' of argument 1 in function 'QMatrix4x2::QMatrix4x2(const float * values)'. 'const float *' of argument 1 in function 'QMatrix4x3::QMatrix4x3(const float * values)'. Change-Id: Iea9ced35158b31fb006d038cd5c307d5feec839e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add QtRemoteObjects classesFriedemann Kleint2019-01-301-0/+1
| | | | | | | | | | | For starters, add the classes so that ready-made classes like QAbstractItemModelReplica can be used. Actually implementing repc requires another step. Task-number: PYSIDE-862 Change-Id: I28adb1d45c262f298f0ad1926198ec6a3013542f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* [reg] Remove createIndex method that uses PyObject*Cristian Maureira-Fredes2019-01-085-15/+13
| | | | | | | | | | | | | | | | | | | | | | Even though we have support for Void*, having to import it as an additional class to be able to call a separate function, is adding too much complexity so something that should be easy to do, like creating an index for an itemmodel. The regression is a change that replaced the way of doing: QAbstractItemModel.createIndex(0, 0, PyObject*) to QAbstractItemModel.createIndex(0, 0, VoidPtr(PyObject*)) which is not really intuitive, and is generating other issues. Included modification in the registries too. Change-Id: Ie6112c6baeb4fc3b22fc78e7edeb66aa4a17c22b Fixes: PYSIDE-883 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Pyside2: Add free functions from namespace QtQmlFriedemann Kleint2019-01-041-1/+5
| | | | | | Change-Id: Ib4a9e8be733a3c8012e19c509ed98f87aad7cb6d Fixes: PYSIDE-892 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix crash when mixing static overloads with instance methods in derived classesFriedemann Kleint2019-01-045-10/+12
| | | | | | | | | | Use METH_STATIC only when there are no instance methods in the same class. Unearthed by a clash of QPlainTextEdit::find() and static QWidget::find(WId). Change-Id: I891c678e004a0abc3937437b0cac26e8094853de Fixes: PYSIDE-886 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix crash related to multiple inheritanceFriedemann Kleint2019-01-031-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | In the <class>_PTR_CppToPython_<class> converter function (written by CppGenerator::writeConverterFunctions()), the generated code used typeid(*ptr).name() to retrieve the name to use for the SbkObjectTypes. This construct returns the name of the outermost class (for example, "QWidget" for a QWidget-type paint device returned by QPainter::device()), as opposed to "QPaintDevice *" returned by typeid(ptr).name(). This caused a crash with multiple inheritance since QWidget inherits QObject and QPaintDevice and the "QWidget" type was associated with the QPaintDevice pointer. To fix this: - Add API to libshiboken to obtain the SbkObjectType* by name and check for the presence of a special cast function (multiple inheritance). - Generate the code of <class>_PTR_CppToPython_<class> as follows: Check whether the outermost type obtained by typeid(*ptr).name() has a special cast function. If that is the case, use the type name obtained by typeid(ptr).name() (base class) to create the wrapper. Change-Id: I8ee6b4c084e9dafa434623433661809b83aedee5 Fixes: PYSIDE-868 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Update after Activate existence_test.py for 5.12Christian Tismer2018-12-274-0/+98441
| | | | | | | | After the existence test war activated, the newly generated files are ready for checkin. Change-Id: I5118b83fab1a1c52c56166aaf4e8b026722966e0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Activate existence_test.py for 5.12Christian Tismer2018-12-221-1/+1
| | | | | | | | | | | | There have been a lot of changes and enhancements when recursive classes were enabled and type hinting was created. When these patches are stable and checked in, this follow-up should be activated and all signature files re-created. Task-number: PYSIDE-735 Change-Id: I0c80c7986a5e02e380760d0a6b89faa7be2be2ba Reviewed-by: Christian Tismer <tismer@stackless.com>
* Complete The Signature IntrospectionChristian Tismer2018-12-223-24/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | The signature module has been quite far developed. In the course of making things fit for the TypeErrors with the signature module, now also all signatures from all shiboken modules are queried. Instead of writing an extra signature existence test for shiboken, it made more sense to extend the existing init_platform.py by the shiboken modules. In fact, by this query a corner case was exploited that worked on Python 2 but assertion-crashed on Python 3. The mapping.py modules were also completed to support all new PySide2 modules. Special care had to be taken because the "shiboken2" module exists both as directory and as binary module. The fix was tricky, and I will add a task that replaces such workarounds by a better design. Task-number: PYSIDE-510 Change-Id: Ibf8e322d1905976a0044a702ea178b7f98629fb4 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Update old copyright messageCristian Maureira-Fredes2018-11-291-1/+1
| | | | | | Change-Id: I083fbeace177b627caef02fce1e738163461f91a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QApplication::setStyle ownership transferCristian Maureira-Fredes2018-11-281-0/+8
| | | | | | | | | | | | | | Due to the nature of the qApp singleton, it was not enough to add the refcount of the style via the typesystem, as usual. An additional step of getting a reference to the qApp to set the parent of the style was required. A test case was included. Change-Id: I5e60983e961e7d3d310b1e1c2f6f9b80ee095308 Fixes: PYSIDE-861 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Exclude reverse operations from shift hackCristian Maureira-Fredes2018-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | An old fix for a QDataStream bug was performing an additional step related reverse operations, to make sure we call them if they were implemented in other classes. This was intended for shift operations. Classes like QVector*, QTransform, and others which include reverse operations like __radd__, and __rmul__ will include this patch too. When implementing a class that inherits from these types, this becomes an infinite loop, which can be solved applying this patch only for shift operations. Due to this change, a QMatrix and a shiboken test needed to be adapted. Change-Id: Ie399837b6435b2cd058648a15f4d5cdff037ac6b Fixes: PYSIDE-192 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Split The Signature Module After The Project SplitChristian Tismer2018-11-246-20/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The PySide project has been split into three pieces, including Shiboken. This had far-reaching consequences for the signature project. Shiboken can be run together with PySide or alone, with tests or without. In every configuration, the signature module has to work correctly. During tests, the shiboken binary also hides the shiboken module, and we had to use extra efforts to always guarantee the accessibility of all signature modules. This commit is the preparation for typeerrors implemented with the signature module. It has been split off because the splitting is not directly related, besides these unawaited consequences. I re-added and corrected voidptr_test and simplified the calls. Remark.. We should rename shiboken to Shiboken in all imports. I also simplified initialization. After "from PySide2 import QtCore", now a simple access like "type.__signature__" triggers initialization. Further, I removed all traces of "signature_loader" and allowed loading everything from PySide2.support.signature, again. The loader is now needed internally, only. Also, moved the type patching into FinishSignatureInitialization to support modules with no classes at all. The "testbinding" problem was finally identified as a name clash when the same function is also a signal. A further investigation showed that there exists also a regular PySide method with that problem. The test was extended to all methods, and it maps now all these cases to "{name}.overload". Updated the included typing27.py from https://pypi.org/project/typing/ from version 3.6.2 to version 3.6.6 . Task-number: PYSIDE-749 Change-Id: Ie33b8c6b0df5640212f8991539088593a041a05c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Improve enum type operations implementationCristian Maureira-Fredes2018-11-203-7/+23
| | | | | | | | | | | | | | | | | | | | | | | The current implementation of the enum operations, wrongly assumes that the first element is always an enum. This patch add some logic to determinate the types we are dealing with, to allow operations like: 2 + QtCore.Qt.Key.Key_1 which were not accepted before. Float numbers are not accepted for enum operations and a test case was included. Some tests were adapted since they were wrongly implemented. Fixes: PYSIDE-830 Change-Id: I407dca2b7c39fc684dbdac19ad45d259403ebadd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add std::nullptr_t supportCristian Maureira-Fredes2018-11-192-0/+57
| | | | | | | | | | | | Shiboken did not have support for `nullptr_t` so the converter was failing when encountering a `nullptr`. A test case is included. Fixes: PYSIDE-854 Change-Id: If5aad245e7074ed791bfc7a42a4c6a56de441d5b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Signature: Implement Nested Classes and Functions for ShibokenChristian Tismer2018-11-151-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch again contains a complete overhaul of the signature module. The code was re-implemented to properly support nested classes. Also, the code was reduced by AutoDecRef and by adopting a concise C++ style. Note.. We will add a shiboken signature test and complete mapping.py after the split into three projects is done. The split changes a lot and is needed right now! Signatures were quite complete for PySide, but the support for Shiboken was under-developed. Since we are planning to generally enhance error messages by using the Signature module, we should be able to rely on them to always produce a signature. Therefore, a general overhaul was needed to resolve all cornes cases for Python 2 and 3. Nested classes are supported, as well as plain module functions. The usage of the typing module might improve over time, but the Signature implementation is now considered complete. The loader will respect now the path settings which might not be the package dir but the build dir. This is more consistens with COIN testing. Task-number: PYSIDE-795 Change-Id: I246449d4df895dadf2bcb4d997eaa13d78463d9b Reviewed-by: Simo Fält <simo.falt@qt.io>
* Remove createIndex method that uses PyObject*Cristian Maureira-Fredes2018-11-132-14/+13
| | | | | | | | | | | | | | | | We have a proper `void*` treatment, so the extra function does not seems to be necessary. The injected code used for the interalPointer method was also removed since is better to leave on shiboken hands the conversion between void* and python types. A couple of test were adapted since wrongly used ModelIndex with Python objects. Change-Id: I082637c7d1dd1bb0f50a3c453513e5d722f4b783 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Revert "Terrible workaround fix for hanging tests on macOS 10.12"Alexandru Croitor2018-10-311-1/+1
| | | | | | | | | | | | | | Once the qtbase commit (22c1a46a03bc3347afc0e7462e19558283d0e1b7) gets integrated into the qt/qt5 repo for dev branch, we can revert the terrible workaround fix, because it won't be needed anymore. This reverts commit 5cd52cda24bf70bf99f4deec037039df0ab928f5. Task-number: PYSIDE-724 Change-Id: I627c7ec945b864a1c16ba6cd7288807591f70140 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide2: Re-enable native event filtersFriedemann Kleint2018-10-261-2/+21
| | | | | | | | | | | Add QAbstractNativeEventFilter. Re-add the native event filter functions on QWindow and QWidget, modified to return a tuple bool/long, using a modification from PySide. Task-number: PYSIDE-790 Change-Id: I86fef1a0c168e69fb3391cd882ea05190985384d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Improve build rules for module generationAlexandru Croitor2018-10-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously whenever a typesystem XML file changed, this resulted in a full rebuild of all cpp files generated for that particular module. This change shifts the rules of building in such a way, that files are rebuilt only if their content has changed. XML modifications should generally not cause full rebuilds anymore, unless the change is in a global header. This is achieved in the following way, assuming a binding library "foo" added by add_library(foo ...): 1) CMake calls shiboken via add_custom_command. 2) The OUTPUT file for the command is the generated mjb_rejected_classes.log file, which serves as a timestamp for when shiboken was last run. 3) All the generated cpp files are marked as "Generated" via the add_custom_command BYPRODUCTS option. This allows the files to have an older timestamp than that of an XML file, thus not forcing constant shiboken re-execution. 4) A new custom target foo_generator is added via add_custom_target. 5) This target has a dependency on the mjb_rejected_classes.log file, and the target itself is added as a dependency to the "foo" target. 6) Whenever "foo" is built, it will first try to build "foo_generator" which will force the shiboken custom command to be run, which will generate the cpp files and mjb_rejected_classes.txt file. The BYPRODUCT cpp files can then be used as sources in the "foo" target. 7) If a user modifies the XML file listed in the add_custom_command DEPENDS option, this will re-trigger shiboken execution, which will create a new mjb_rejected_classes.log file, which means that the "foo" target might be rebuilt if, and only if, any of the cpp file timestamps are new. Otherwise "foo" doesn't need to be rebuilt. Change-Id: I9a3844a2fa775106288acc01cb4570a903e16991 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* libpyside: Port DynamicQMetaObject to QMetaObjectBuilderFriedemann Kleint2018-10-221-0/+6
| | | | | | | | | | | | | | | | | | | | Qt 5 introduces a new class QMetaObjectBuilder for generating dynamic meta objects for use cases like QML. It provides an API to add methods, properties and info and a factory method toMetaObject() to obtain a QMetaObject snapshot reflecting the changes. Replace the DynamicQMetaObject aggregated by TypeUserData by a class MetaObjectBuilder wrapping a QMetaObjectBuilder with dirty-handling. The code to create the binary data of the QMetaObject can then be removed. For plain Qt objects, the wrapped base meta object will be returned (which fixes the bug). Task-number: PYSIDE-784 Change-Id: Id8a54570aff36c75fe0f3bf2d297a12d02cd773a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Prepare the Signature Module For More ApplicationsChristian Tismer2018-10-111-86/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the preparation for a number of planned applications and extensions using the signature module. This general overhaul contains: - Extraction of signature enumerations into enum_sigs.py, - a list of current keyword errors in arguments which are unsolved in shiboken, but temporarily fixed in parser.py (too many for XML), - fix spurious duplications in multiple signatures - corrections for keyword errors in function names which cannot be fixed by Python (quite few), - fixing "..." arguments into "*args", - supporting the "slot wrapper" type. This is necessary for methods like "__add__", "__mul__" etc. - Create an extra function "get_signature" that has a parameter to modify the appearance, i.e. without self, without returntype, etc. Task-number: PYSIDE-510 Change-Id: If16f7bf02c6e7cbbdc970058bb630ea4db2b854a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Simplify and correct the new_inherited_functions testChristian Tismer2018-10-081-86/+67
| | | | | | | | | | | | | | | | | | | | | | The test was written when PySide2 did not have the "from PySide2 import *" feature. It was written with "try..except" constructs to find the translated modules. This did not work correctly due to the path settings in ctest. When not all modules are selected, they are still partially importable! For instance, PySide2.QtPrintSupport could be imported, although it was not compiled, and then complained since a function was not found. This is possible, because python 3 supports module directories without an __init__.py file. (I was always against that "feature".) Instead of adjusting the path setting, this patch uses the above feature and does not rely on "importability". Task-number: PYSIDE-331 Change-Id: I9aed4971f10f423918525cf411fd7ff713f40e48 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-09-213-0/+55868
|\ | | | | | | Change-Id: Ie4320a6ac584ec47ed8eaca538453a8e5b123c42
| * Update the Registry After Explicit Linux NamingChristian Tismer2018-09-133-0/+55868
| | | | | | | | | | | | | | | | | | | | | | Linux is now renamed in a way that the Linux distributions are recognized. The names are a _bit_ verbose, but this works, at least :-) Task-number: PYSIDE-510 Change-Id: Icd52cc92aa0e0b9c6e6b38e632cb89d09766c190 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | PySide2: Base the QMatrix<R>x<C> on QGenericMatrixFriedemann Kleint2018-09-141-1/+14
| | | | | | | | | | | | | | | | | | | | After fixing non-type templates, QGenericMatrix can be specified as their base class. The inherited functions can then be used instead adding templates. Change-Id: I5ec435cf04d8443626a86a78643e2ad5d29f4a5e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-09-133-2/+37691
|\| | | | | | | Change-Id: I7f60b78b0c962e4faf3688581e7f550813d1a413