aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pyside.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup pointer whitespace everywhereChristian Tismer2019-06-241-44/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix negative refcount on QSocketNotifierChristian Tismer2019-06-101-0/+1
| | | | | | | | | | | | | | | 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>
* PySide: Allow any existing attribute in the constructorChristian Tismer2019-06-041-16/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libpyside: Port DynamicQMetaObject to QMetaObjectBuilderFriedemann Kleint2018-10-221-6/+5
| | | | | | | | | | | | | | | | | | | | 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>
* libpyside: Introduce helper functions for accessing TypeUserData and meta ↵Friedemann Kleint2018-10-161-13/+37
| | | | | | | | | | | | objects Add helpers with overloads to reduce reinterpret_cast<> and increase type safety. Task-number: PYSIDE-784 Change-Id: I334fd7d149a6730094b062dd0371b9a29379d725 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* libpyside: Clean up #include directivesFriedemann Kleint2018-10-021-11/+12
| | | | | | | | | | Remove unused #include directives, group by libpyside, libshiboken, Qt, C++ and sort alphabetically with the exception of sbkpython.h which sanitizes the "slot" defines and needs to go to the top when used). Add the module to the Qt classes. Change-Id: I33d912135bad928d3073a1ddeb487de237d6a45e Reviewed-by: Christian Tismer <tismer@stackless.com>
* libpyside: Fix reinterpret_casts related to DynamicQMetaObjectFriedemann Kleint2018-09-281-10/+5
| | | | | | | | | | | | | | Previously, DynamicQMetaObject instances were retrieved by direct reinterpret_cast from the SBK user data. This is not entirely correct since the DynamicQMetaObject is merely the first member of the struct TypeUserData. Fix this by moving the struct TypeUserData to a private header and correcting the casts. Task-number: PYSIDE-784 Change-Id: I69ea68bd474c4a38a5f5c5bc3db8bc3bb086e012 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-09-041-0/+2
|\ | | | | | | Change-Id: Ie8025300580981c5349b31d4846a7f659481991d
| * PySide2: Fix compilation with a with custom namespace specified for QtFriedemann Kleint2018-08-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | Add missing QT_BEGIN/END_NAMESPACE macros. Patch as provided on bug report. Task-number: PYSIDE-635 Change-Id: I7ddb447f1aafeb8da72e7e192905bafe3809797d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | libpyside: Fix clang-tidy warnings about class definitionsFriedemann Kleint2018-08-311-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add override - Use = default for trivial constructors/destructors - Add Q_DISABLE_COPY where applicable - Use member initialization and remove constructors from simple structs - Use explicit where applicable (which requires adapting code snippets constructing a QVariant from PyObjectWrapper) - Fix some parameter to take a const ref or pass by value and use std::move in constructors Change-Id: I5e0d2c4ef92d20397a7daba2f8a64b507e678510 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | libpyside: Fix remaining clang-tidy warningsFriedemann Kleint2018-08-301-3/+3
|/ | | | | | | | | | | - Remove else after return/continue/break; unindent code or simplify return conditions - Use isEmpty() to check for empty containers - Fix C-style casts - Pass std::size_t by value instead of const ref Change-Id: Ic997d7c39720c1cd3698c4d750e9cfc1f1654788 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Pep 384 Final Cut: Remove PepTypeChristian Tismer2018-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | While trying to document the Limited API Project, it suddenly struck me: We can make the patch much much simpler and implement it without the necessity to have an extra PepType! Now I am happy to continue the documentation, because it is now no more improvable. This version will last as long as the layout of PyTypeObject does not change substantially. When that happens, then we need to rewrite stuff with the according PyType_GetSlot() access functions. These access functions will until then be complete enough so that we can live without the tricks like inventing a reduced PyTypeObject as was done in the current implementation. Task-number: PYSIDE-560 Change-Id: I49849cc377baa6794a5b53292691e21d6e2853ab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove QT_LOGGING_RULES to fix QLibraryPath pathsCristian Maureira-Fredes2018-06-211-18/+0
| | | | | | | | | | | | | QT_LOGGING_RULES was internally overwriting the PySide2 QLibraryPath configuration, so all the paths were incorrect. Please follow PYSIDE-717 for a discussion on an alternative to have a proper solution. Task-number: PYSIDE-694 Change-Id: I551d7876a416ac31fcff70d843a28c98dfa5ed08 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* PEP 384-squash: Implement PEP 384Christian Tismer2018-05-301-4/+4
| | | | | | | | | | This is the condensed checkin of 18 commits which created the implementation of PEP 384. Task-number: PYSIDE-560 Change-Id: I834c659af4c2b55b268f8e8dc4cfa53f02502409 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change license from all the filesCristian Maureira-Fredes2018-05-031-1/+1
| | | | | | | | | | | | | | | | | Removing the word 'project' from all the headers, and changing the PySide reference from the examples to Qt for Python: The following line was used inside the source/ and build_scripts/ directory: for i in $(grep -r "the Qt for Python project" * |grep -v "pyside2-tools" | awk '{print $1}' | sed 's/:.*//g');do sed -i 's/the\ Qt\ for\ Python\ project/Qt\ for\ Python/g' $i;done and the following line was used inside the examples/ directory: for i in $(grep -r "of the PySide" * |grep -v "pyside2-tools" | awk '{print $1}' | sed 's/:.*//g');do sed -i 's/of\ the\ PySide/of\ the\ Qt\ for\ Python/g' $i;done Change-Id: Ic480714686ad62ac4d81c670f87f1c2033d4ffa1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Rename PySide references to Qt for PythonCristian Maureira-Fredes2018-04-271-1/+1
| | | | | | | | | When referring to the project one should use "Qt for Python" and for the module "PySide2" Change-Id: I36497df245c9f6dd60d6e160e2fc805e48cefcae Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Improve qt.conf registration handlingAlexandru Croitor2018-04-201-1/+40
| | | | | | | | | | | | | | | | | | | | | | When PyInstaller is used to deploy a PySide2 application, it changes the layout of the copied PySide2 files (no Qt subfolder, all shared libraries are copied next to tehe generated executable). In that case using the internal qt.conf won't work. Detect if there a exists a qt.conf file next to the executable, and use that file instead. Note that this won't work when the executable path has unicode characters in conjunction with Python 2 and Windows, but that is an unsupported config anyway (due to the mixing MSVC issue). Also add a logging category to ease figuring out which qt.conf file is used if a need ever arises to do so. Task-number: PYSIDE-642 Change-Id: I1260cbc13e5e62be72c4ed9c64c2aa5905d2e9c6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix QtWebEngineProcess related issues on the supported platformsAlexandru Croitor2018-04-201-1/+8
| | | | | | | | | | | | | | | | | | There were 2 issues: 1) QtWebEngineProcess could not be found on Windows because we have a non-standard directory layout for the Qt files we copy over (there is no bin directory), so we need to adjust the internal qt.conf which is set in pyside.cpp 2) QtWebEngineProcess itself does not use the qt.conf from pyside.cpp, because it is a separate executable, and thus we need to supply a qt.conf specifically for it which is placed in the libexec folder. Task-number: PYSIDE-626 Task-number: PYSIDE-631 Task-number: PYSIDE-642 Change-Id: I75d1b083fb5afe5dc31ba90174f42c7f559c5cd5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* fix more qApp crashesChristian Tismer2018-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | When building PySide with a debug Python, a lot more problems become visible. They were triggered by some malicious ordering of the shutdown code, which must come *after* the refcounts of the variables are adjusted. The initial issue PYSIDE-585 was caused because the shutdown code is not only used for every created Q*Application, but also for the module shutdown, which deletes qApp_contents too often. Instead of special-casing that or adding some refcount, it was much more intuitive in that context to set qApp_content's refcount to the same value as Py_None, which also is not supposed to be garbage collected. Btw., the reason for the error message is that Py_None has it, too. When we set qApp_content's type to Py_None's type, it inherits the protection code that prevents someone from garbage collecting Py_None. Task-number: PYSIDE-585 Change-Id: I4af9de1192730f06054a5aca099a32e2392e367d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Make standalone installations relocatableAlexandru Croitor2017-11-151-1/+129
| | | | | | | | | | | | | | | | | | This is achieved by registering a qt.conf file with a Prefix pointing to a directory relative to the loaded PySide2 module (e.g. QtCore). Thus Qt does not crash due to not finding platform plugins. Because this change would affect tests, which are ran before the PySide package is installed, a new environment variable called PYSIDE_DISABLE_INTERNAL_QT_CONF is introduced. This variable disables the registration of the internal qt.conf file, thus it will not point to a not yet created location, which will allow tests to run as before. Change-Id: I5a96037adfafe1f08ea57535aa4a2a0d1660dfaf Task-number: PYSIDE-558 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Remove dead / unused code regarding conversionsAlexandru Croitor2017-11-021-2/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* Support the qApp macro correctly, final version incl. debugChristian Tismer2017-10-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* move everying into sources/pyside2Oswald Buddenhagen2017-05-221-0/+387
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.