aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2
Commit message (Collapse)AuthorAgeFilesLines
* Remove extra ref on QDataStream::setDeviceCristian Maureira-Fredes2019-09-061-6/+0
| | | | | | | | | | | According to the documentation the object does not take ownership of the QIODevice. Change-Id: I1a617844fd825e6420167c4a5d848fd36e90823f Fixes: PYSIDE-1007 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* correct QtPrintSupport dependencyChristian Tismer2019-07-292-1/+1
| | | | | | | | | | | | | | | QtPrintSupport was missing the XML entry QtWidgets in typesystem_widgets_common.xml, which resulted in follow-up errors in generate_pyi . With this addition, the following pointer-types patch will create a correct signature def getPageMargins(self, unit: PySide2.QtPrintSupport.QPrinter.Unit) -> typing.Tuple[float, float, float, float]: ... Task-number: PYSIDE-951 Change-Id: I0b87cc31c3b39e727aec0a433687a131f1dc1aa6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Allow for "auto" as target of type for CONVERTTOCPP in injected codeFriedemann Kleint2019-07-291-3/+2
| | | | | | Task-number: PYSIDE-1037 Change-Id: Idfc70fe571e4058d0c82db1bd0afea54436fe27c Reviewed-by: Christian Tismer <tismer@stackless.com>
* Cleanup signature module before substantial changeChristian Tismer2019-07-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | There were some refinements applied while developing "Support Pointer Primitive Types by Arrays or Result Tuples". This patch moves these changes out which are not essential for that patch. They include - sort all mapping groups by name - replace huge regex by a pattern generator - replace dictionary string entries by SimpleNameSpace - improve PEP 563 handling - simplify "zero(sometype)" substantially - better handling of "QGenericMatrix" (preview) A test for the generated pattern against a reference parser was added. Task-number: PYSIDE-795 Task-number: PYSIDE-951 Change-Id: I5a6b236850c63a7db77b7f7b88881486fd1e61be Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add optional support for types in QSettings::valueCristián Maureira-Fredes2019-07-172-5/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* PySide2/QtCore: Remove duplicated type entry for "bool"Friedemann Kleint2019-07-041-1/+0
| | | | | | | Another entry with converters exists a few lines below. Change-Id: Id1de3835e42869a55e0bf865aa992f38748f2e88 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Leave QVariantMap as a name, not a typeCristian Maureira-Fredes2019-07-022-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem happened on the QtLocation module, when the QVariantMap argument was being used in several functions, and this type was declared as a primitive-type in QtCore. An approach to change the type to a container-type failed, because since QVariantMap is a typedef, is was already registered as a name associated to the definition QMap<QString, QVariant>. The solution was to register the name at the beginning of the module (like QVariantList), and remove the type declaration, leaving it only as a name. Previously, the wrongly generated code looked like this: Shiboken::Conversions::PrimitiveTypeConverter<QVariantList>() but with this patch, it looks like: SbkPySide2_QtLocationTypeConverters[SBK_QTLOCATION_QMAP_QSTRING_QVARIANT_IDX] which is the proper name established by the code on glue/qtcore.cpp: Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QTCORE_QMAP_QSTRING_QVARIANT_IDX], "QVariantMap"); Change-Id: Id172cf5b1e3ac784bc9497359279e81fcba1d8ec Fixes: PYSIDE-1028 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Cleanup pointer and trailing whitespace (omissions)Christian Tismer2019-06-256-17/+17
| | | | | | | | | | | | | | | | | 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-2419-309/+314
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix negative refcount on QSocketNotifierChristian Tismer2019-06-101-2/+2
| | | | | | | | | | | | | | | Change 43451e3bc17467593df64cb73ce8c0bf9e60045f from 2018-05-09 introduced a refcount bug that was not caught because we do not build with debug Python. This also revealed an omission in the patch "PySide: Allow any existing attribute in the constructor" when debug Python is used. Change-Id: Idbcbbc87f0a83bb696d03e05af0cf616b21f7335 Fixes: PYSIDE-1027 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Make it possible to extend namespacesFriedemann Kleint2019-05-222-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* generate_pyi: Simplify, Enhance and Get Rid Of Any Import ProblemsChristian Tismer2019-05-191-152/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The generate_pyi.py script always had the problem that it was not easy to distinguish different kinds of ImportError. When ImportError was raised during a build, we assumed it was just a not-yet built module and ignored it. When patch 97df448e "Modernize cmake build" was checked in on 2019-02-07, a real import error was introduced on Windows. It was not recognized until 2019-05-13 that Windows had stopped generating .pyi files. It was discovered by working on an enhancement to dependency checks that erroneously looked for "libshiboken*" on windows. This should have raised an error in "generate_pyi.py" but did not, because the generation was skipped due to the real ImportError. General Redesign ---------------- It turned out that all the former difficulties with importing modules could be completely avoided, by explicitly using the inherent dependencies. The script was drastically simplified by using the module name as an argument. It was not clear in the first place that this would work, but actually we recognized that all modules a script wants to import are already built when CMake starts the .pyi generation. The only visible quirk is the pair QtMultimedia/QtMultimediaWidgets where both modules must be compiled before generating. (maybe that is an error in our XML files, or a Qt "feature"?) Enhancements ------------ The generate_pyi script is now completely deterministic, because all imports are enforced to work. There is no more polling for translated modules necessary. Everything is generated after a module was linked, The "--skip" semantic was first enhanced much further. In the end it was recognized that we don't need the parameter any longer, because with the determinism we are never computing a pyi file more than once. The parameter was then completely removed. The "--check" option was added for Python 3. It takes some time and is only automatically active in a COIN build. Task-number: PYSIDE-735 Change-Id: I3cc58f6cad80d8208e17f62d472fd48aa6aeebd6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add PySide2: Add OpenGL version functions as separate moduleFriedemann Kleint2019-05-0229-10/+1645
| | | | | | | | | 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>
* Avoid too much stickiness when using --reuse-buildChristian Tismer2019-04-261-2/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We had some unwanted cache effects and needed to manually remove certain files before building. Otherwise it could happen that a build pretended to be ok, although there was a bug that prevented generation of the ".pyi" files. Further investigation showed: Using option "--reuse-build" with "no" and then with "yes" creates errors in the signature module. This makes "reuse-build" useless in this case. We now add an "a" to "pyside3d_build" as "pside3da_build" if "--limited-api=yes" was given. (different proposals welcome.) That solved most of the stickiness problems. A left-over lock directory is removed now, since it would prevent re-computation of the .pyi files. This is implemented by a recursive call to the script, where the subprocess does the work and the main process checks if there was a crash and removes the lock. The "--skip" parameter of generate_pyi.py was refined: When set, it is checked if the time stamp of all imported modules is less than the ".pyi" file time stamp. Only then the generation is skipped. By editing any involved python file, the ".pyi" files will be regenerated. Task-number: PYSIDE-560 Change-Id: I1b1d8ffbc58db3d4b38bf65e3795efcad7e7870c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix warnings about signatures 'setUniformValue(const char*,...)' not being foundFriedemann Kleint2019-04-261-6/+1
| | | | | | | | | | | | | | | | | | | 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>
* Add explicit methods for QOpenGLShaderProgramm.setUniformValue (i/f)Cristian Maureira-Fredes2019-04-242-0/+30
| | | | | | | | | | | | | | | | | | | Selecting which overload to use is in hands of the shader program code that defines the type, then it is better to explicitly call signatures that are overloaded using number types, specially for OpenGL. This change will help with PYSIDE-989, because it will allow to call `setUniformValue1f` without having the problem of using the generic `setUniformValue` that will end in calling the wrong method (the integer one). Since the primitive type conversion is a separate global issue, another task has been opened PYSIDE-1000. Task-number: PYSIDE-989 Change-Id: I77e5616e081e570bee880a1a403faf3cf6c55099 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Declare XML files to be in encoding UTF-8Friedemann Kleint2019-04-1864-64/+64
| | | | | | | | 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>
* Make the PepType_AS_BUFFER definition completeChristian Tismer2019-04-161-4/+0
| | | | | | | | | | PepType_AS_BUFFER should also be defined for the non-Limited API version to avoid ugly #ifdef constructs. This patch augments the definition and simplifies qtcore.cpp . Change-Id: Iddfb39e8afaf992f4edf72d871eec1eaf85d5963 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Revert an unwanted debug change in generate_pyi.pyChristian Tismer2019-04-161-5/+1
| | | | | | | | | | | During the complications with embedding and PyInstaller, an error condition was temporarily left in the code. It is now removed. Change-Id: I9113081dbbcbc84534517c72308eb1d25fbf201c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add array modification for QGLShaderProgram::setAttributeArray(int,const ↵Friedemann Kleint2019-04-151-0/+3
| | | | | | | | float *v,int,int) Change-Id: Ia44c94995bee2f095f1e90b614f9f1cdbc1dde3c Task-number: PYSIDE-988 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Implement Embedding To Make Signatures Always AvailableChristian Tismer2019-03-202-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-209-634/+17
| | | | | | | | | | | | | | | | | | | | | | 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-7/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add ownership to QGraphicsItemGroup.addToGroupCristian Maureira-Fredes2019-03-051-1/+7
| | | | | | | Change-Id: I0c3741133072762443d80663be02a70abf9cc9ef Fixes: PYSIDE-95 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Update link to shiboken's words of advise pageCristian Maureira-Fredes2019-03-041-1/+1
| | | | | Change-Id: Ie2c1c7b9feefb56a9e987f71806a2ce400578fe8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Amend The Python 3.5 FixChristian Tismer2019-03-011-10/+0
| | | | | | | | | | | | 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-0/+10
| | | | | | | | | | | | | | | | | | | 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>
* Add setPageSize new signature to QPageSizeCristian Maureira-Fredes2019-02-262-0/+49
| | | | | | | | | | | The generated code only takes an enum from the meta class (QPagedPaintDevice) as valid argument of the function `setPageSize` (QPagedPaintDevice::PageSize), but it should also accept a QPageSize argument. Change-Id: Ia31a69a5e52e781844ce6a7e4ff6e5e95d17563d Fixes: PYSIDE-940 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Set proper parent when overloading QUiLoaderCristian Maureira-Fredes2019-02-251-0/+3
| | | | | | | | | | | | | | | In a couple of methods of QUiLoader, we had a parent override leaving the methods without the proper parent. setParent(pyArgs[0], pyResult) # Correct setParent(self, pyResult) # Wrong override Defining the ownership to the target class corrects this issue and just leaves the "Correct" approach. Fixes: PYSIDE-938 Change-Id: Id20d74756e14c58caba2ab4c65484d15da88df16 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add common QPrintSupport typesystem for QWebEngineCristian Maureira-Fredes2019-02-255-3/+55
| | | | | | | | | | | Moved around the files so we have a general QPrintSupport typesystem that we can include in other modules that need it, like QWebEngine. Change-Id: Ic277c37e6b0c08b370102d1bef18cd1375239169 Task-number: PYSIDE-946 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Return PyObject wrapper when not valid QVariantCristian Maureira-Fredes2019-02-081-6/+10
| | | | | | | | | | | | | | When resolving the meta type of QVariant we did not have a fallback case. So we had a NoneType when none of the converters worked. These changes allow to return a PyObjectWrapper of the object instead of NoneType. This allow users to use any type as QVariant. Change-Id: I18da3f10f6839975fdc0bf2ac62f6bd7063312df Fixes: PYSIDE-45 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Modernize cmake buildAlexandru Croitor2019-02-0746-179/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Type Hints: Handle Container Types Correctly: AddendumChristian Tismer2019-02-061-0/+1
| | | | | | | | | | | | | | The correction to container types has a small bug which does not exist in reality, but could give a problem in the future: - We need not only avoid instantiation in Missing, but generally in all _NotCalled classes. Otherwise, when called during processing of container types, they would loose their (Missing, Default, ...whatever) tag. Change-Id: I4eb154100da6f3067b816c190af314b2a710ff39 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* typesystem_gui_common.xml: CleanupFriedemann Kleint2019-02-061-30/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* Type Hints: Handle Container Types CorrectlyChristian Tismer2019-02-051-18/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An error was reported that we had a bug in this .pyi line: def parseErrors(self) -> PySide2.QtScxml.QScxmlError: ... which actually had to be a list like def parseErrors(self) -> typing.List[PySide2.QtScxml.QScxmlError]: ... A deeper look revealed that we had very many other examples, also in the argument lists, were we did not handle containers properly. (For example, 90 times in QtCore!) This is a leftover from the type error messages which were generated in C++, and never really understood. This is now a clean rewrite of the C++ part to expose all information and an extension of the Python parser that systematically uses the container types from the typing module. The implementation became a bit more complex because of Python 2: We need to provide our own copy of the public typing module, because it is not safe to assume that this module can be loaded. Importing it from support.signature gave a problem because we now need to find the names of instances to produce List[...], which needed to be implemented in the loader. Implemented the "Pair" type now as a native generic type. This is more correct than the former implementation and shorter in the .pyi files. Additionally, an own definition of "Char" was provided for brevity. This was not important to implement and could also be done with "int", but it is helpful for the future to know how to implement own types (and it was fun). Task-number: PYSIDE-921 Task-number: PYSIDE-795 Change-Id: I0e565b38d7b4fff39dd606950f9f8d97c45acbf5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide2/QtSxcml: Support bool *ok in some of the models' evaluateTo() functionsFriedemann Kleint2019-02-042-0/+17
| | | | | | | | | | | | | | | | | Add yet another version of the fix_args,arg,bool template, fixing: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'bool *' of argument 2 in function 'QScxmlDataModel::evaluateToBool(int id, bool * ok)'. 'QScxmlDataModel::evaluateToString(int id, bool * ok)'. 'QScxmlDataModel::evaluateToVariant(int id, bool * ok)'. 'QScxmlEcmaScriptDataModel::evaluateToBool(int id, bool * ok)'. 'QScxmlEcmaScriptDataModel::evaluateToString(int id, bool * ok)'. 'QScxmlEcmaScriptDataModel::evaluateToVariant(int id, bool * ok)'. 'QScxmlEcmaScriptDataModel::evaluateToVoid(int id, bool * ok)'. 'QScxmlNullDataModel::evaluateToString(int id, bool * ok)'. 'QScxmlNullDataModel::evaluateToVariant(int id, bool * ok)'. Change-Id: Idfda2adc0875a4626797a92240fa5267016d04bb Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide2/QtGui: Add more array modifications for const (unsigned) int * ↵Friedemann Kleint2019-02-011-1/+13
| | | | | | | | | | | | | | | | | parameters Fix warnings: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const unsigned int *' of argument 5 in function 'QOpenGLExtraFunctions::glDebugMessageControl(unsigned int source, unsigned int type, unsigned int severity, int count, const unsigned int * ids, unsigned char enabled)'. 'const int *' of argument 3 in function 'QOpenGLExtraFunctions::glSamplerParameterIiv(unsigned int sampler, unsigned int pname, const int * param)'. 'const unsigned int *' of argument 3 in function 'QOpenGLExtraFunctions::glSamplerParameterIuiv(unsigned int sampler, unsigned int pname, const unsigned int * param)'. 'const int *' of argument 3 in function 'QOpenGLExtraFunctions::glTexParameterIiv(unsigned int target, unsigned int pname, const int * params)'. 'const unsigned int *' of argument 3 in function 'QOpenGLExtraFunctions::glTexParameterIuiv(unsigned int target, unsigned int pname, const unsigned int * params)'. 'const unsigned int *' of argument 2 in function 'QOpenGLFunctions::glShaderBinary(int n, const unsigned int * shaders, unsigned int binaryformat, const void * binary, int length)'. Change-Id: I764823352fc4360d167acb07e8502a1dc8c060dc Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* PySide2: Remove enumeration AbstractPhysicalDevice::DeviceStatusFriedemann Kleint2019-02-011-3/+1
| | | | | | | | Fix warning: enum 'Qt3DInput::QAbstractPhysicalDevice::DeviceStatus' is specified in typesystem, but not declared Change-Id: I2d241e6c524cce84fc090fec3eca4595beb998d0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* QtGui: Fix warning about <array> modificationFriedemann Kleint2019-02-011-1/+1
| | | | | | | | | | Extend the regexp for the <array> modification of glClearBufferXX() to actually check for '*' so that only the overloads with arrays match, fixing warning: glClearBufferfi(uint,int,float,int): Cannot use parameter 3 as an array: Type does not have indirections. Change-Id: Ic1cd24ca3d66ea7eac593b4a2d3b1a759ab1af18 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide2/Widgets: Add overload of QInputDialog::getDouble()Friedemann Kleint2019-01-312-0/+18
| | | | | | | | | | | | | Add modification and new variant of the fix_arg template, fixing warning: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'bool *' of argument 8 in function 'QInputDialog::getDouble(QWidget * parent, const QString & title, const QString & label, double value, double minValue, double maxValue, int decimals, bool * ok, QFlags<Qt::WindowType> flags, double step)'. Change-Id: I02ee5c477d74698bd5dda23bbec01f39775d5c6d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide2: Remove non-existent or moved Qt3D classesFriedemann Kleint2019-01-312-9/+0
| | | | | | | | | | | | Fix warnings: (3dcore) type 'Qt3DCore::QAbstractEngine' is specified in typesystem, but not defined. This could potentially lead to compilation errors. (3dcore) type 'Qt3DCore::Quick::QQmlAspectEngine' is specified in typesystem, but not defined. This could potentially lead to compilation errors. (3drender) type 'Qt3DRender::AssimpImporter' is specified in typesystem, but not defined. This could potentially lead to compilation errors. (3drender) type 'Qt3DRender::GLTFExporter' is specified in typesystem, but not defined. This could potentially lead to compilation errors. (3drender) type 'Qt3DRender::GLTFImporter' is specified in typesystem, but not defined. This could potentially lead to compilation errors. Change-Id: Iee873d69214e8195bfbd72bb664b691dd01d6877 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide2: Fix some build warningsFriedemann Kleint2019-01-313-1/+3
| | | | | | | | | - Add enum QJSValue::ErrorType - Add enum QWebEngineDownloadItem::DownloadType - Adapt suppressed warnings in XML class Change-Id: I0d598b256cf8f83253cdb7684dc4f8c3050a76e2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add classes QWebEngineHistory, WebEngineHistoryItemFriedemann Kleint2019-01-302-5/+3
| | | | | | | Fixes: PYSIDE-906 Change-Id: I612a8881d530bb098d9e2991fd47a15bc454b2d6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add QtRemoteObjects classesFriedemann Kleint2019-01-302-0/+118
| | | | | | | | | | | 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>
* QtCore snippets: Fix warning about printf() format in generated codeFriedemann Kleint2019-01-301-1/+2
| | | | | | | | | | Add a cast to int for value_length and slicelength, fixing: qbytearray_wrapper.cpp:5288:158: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘Py_ssize_t {aka long int}’ [-Wformat=] PyErr_Format(PyExc_ValueError, "attempt to assign %s of size %d to extended slice of size %d",Py_TYPE(_value)->tp_name, value_length, slicelength); Change-Id: I4bd2e5d43a26c73c21a6121b469f5ec1c76994b2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Run generate_pyi After Generation of All BinariesChristian Tismer2019-01-221-1/+15
| | | | | | | | | | | | | | | | | | | | In COIN, there is a racing condition under Windows: Python opens as many modules as it can, while the build process is not yet done. This can lead to the situation that a module is loaded by Python before the Windows Manifest Tool has been run, and that creates a crash. We therefore wait when COIN is run, until all binaries have been created. That means that we are the last process, and the tool must have been already run. In non-COIN builds it is more convenient when in case of errors the generator crashes early. Task-number: PYSIDE-735 Change-Id: I060dbd54432778f14f74830596f28b4db83a0692 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix a crash when overriding ↵Friedemann Kleint2019-01-141-2/+4
| | | | | | | | | | | | | | QAbstractNativeEventFilter.QAbstractNativeEventFilter() long * result is nullptr for the custom message WM_USER + 1 internally used by Qt (cf QEventDispatcherWin32::processEvents()). Add a check for that. Amends 899b3cfed8e1c3513f8d3001c53b0bb0cc1af548. Task-number: PYSIDE-790 Change-Id: I4c55cfb17aa95d79f728f43a9030d1f1cbb1d024 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix snippet typoCristian Maureira-Fredes2019-01-111-1/+1
| | | | | Change-Id: Ic38aa8ba9a2470c97eb5cbd83b7d227322207db9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Produce TypeError Messages Using the Signature ModuleChristian Tismer2019-01-101-0/+1
| | | | | | | | | | | | | | | The TypeError messages can now be produced, based upon the signature module. As a feature under test, we produce ValueErrors instead in certain cases. This will probably improve, later. We are currently investigating how much can be determined, automatically. Task-number: PYSIDE-795 Change-Id: Ie8a648beaf8a3bed388e3c01ba501bb36859722e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>