From c20d35d58dec8cb24914794956f8b0da5c335300 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 19 Dec 2019 14:35:26 +0100 Subject: Fix building without doc generator The generator subproject would still add the qtdocgenerator source file even if neither QtXmlPatterns nor libxml/libxslt2 were found, causing link errors. This is since the value of DISABLE_DOCSTRINGS was not propagated up from the ApiExtractor subproject. Set it to the parent scope from there as well. Change-Id: If8dc7b0437ef8a8c1e71d822328bcc3809252b57 Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/ApiExtractor/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sources') diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt index c2a4c208e..65150eb92 100644 --- a/sources/shiboken2/ApiExtractor/CMakeLists.txt +++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt @@ -46,6 +46,9 @@ if(NOT Qt5XmlPatterns_FOUND AND NOT HAS_LIBXSLT) "Documentation will not be built due to missing dependency (no Qt5XmlPatterns found).") endif() +# Export to parent scope so that generator/CMakeLists.txt gets it +set(DISABLE_DOCSTRINGS ${DISABLE_DOCSTRINGS} PARENT_SCOPE) + add_library(apiextractor STATIC ${apiextractor_SRC}) target_include_directories(apiextractor PRIVATE ${CLANG_EXTRA_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} -- cgit v1.2.3 From 7baa4c91c7d9922256fb045fc64bc196d3333289 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Tue, 17 Dec 2019 23:54:43 +0100 Subject: Fix the registry after QTEST_ENVIRONMENT=ci was restored Since the QTEST_ENVIRONMENT variable was no longer set, a number of crucial checks were not performed. One side effect are the two new keys which were missing in the registry. Additionally, the registry is missing very many entries on macOS, and I have no idea what the reason is. This could be an effect of the macOS 10.15.1 version or of my maybe outdated Qt 5.14.0 version. The registry files from 2019-10-31 have all entries. If I build that version from 2019-10-31 and test it, I get the same missing keys. Therefore, I doubt my results quite a bit! To verify this, we simply check this change in, together with https://codereview.qt-project.org/c/pyside/pyside-setup/+/284809 If that works, then I have a serious bug somewhere, but we know then that the harm of that CI bug was a minimum. Fingers crossed!! Change-Id: I25555d60d6911fca6de67110c35dff8d23c2fd8a Reviewed-by: Friedemann Kleint --- .../shibokenmodule/files.dir/shibokensupport/signature/mapping.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sources') diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 2110ebe7a..0767e8fd4 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -489,6 +489,10 @@ def init_PySide2_QtCore(): PySide2.QtCore.QCborStringResultByteArray, "PySide2.QtCore.QCborStreamReader.StringResult[QString]": PySide2.QtCore.QCborStringResultString, + "PySide2.QtCore.QCborStreamReader.QCborStringResultByteArray": + PySide2.QtCore.QCborStringResultByteArray, # 5.14, why? + "PySide2.QtCore.QCborStreamReader.QCborStringResultString": + PySide2.QtCore.QCborStringResultString, # 5.14, why? "PySide2.QtCore.QUrl.ComponentFormattingOptions": PySide2.QtCore.QUrl.ComponentFormattingOption, # mismatch option/enum, why??? "PyUnicode": typing.Text, -- cgit v1.2.3 From 0b6dd91fbd02e4de1f653e2a8cd6e892628dac0c Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Wed, 13 Nov 2019 19:12:16 +0100 Subject: qApp: Ensure QtCore import when embedded QApplication subclass is used The qApp machinery works great with Python. When using embedding, things are different because there is no longer a wrapper layer. Unfortunately, many extension modules use C++ to derive a QApplication class. This has the side effect that when a foreign C++ module gets imported, the qApp machinery does not see it as it would in Python. Instead of a complex analysis, we always make sure that QtCore is imported. It will report the right instance, anyway. This change could not easily be tested. It was confirmed as a solution by Antonio Rojas. Change-Id: Ie9c56ac75e6c0ae3ace615dfc26c6d218ff4efea Fixes: PYSIDE-1135 Reviewed-by: Friedemann Kleint --- sources/shiboken2/libshiboken/qapp_macro.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sources') diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp index 306f53b74..c2018bd6f 100644 --- a/sources/shiboken2/libshiboken/qapp_macro.cpp +++ b/sources/shiboken2/libshiboken/qapp_macro.cpp @@ -246,7 +246,14 @@ NotifyModuleForQApp(PyObject *module, void *qApp) * qApp_contents variable and assigns the instance, instead of vice-versa. */ PyObject *coreDict = qApp_moduledicts[1]; - if (qApp != nullptr && coreDict != nullptr) { + if (coreDict == nullptr) { + // PYSIDE-1135: Make sure that at least QtCore gets imported. + // That problem exists when a derived instance is created in C++. + qApp_moduledicts[1] = Py_None; // anything != nullptr during import + coreDict = PyImport_ImportModule("PySide2.QtCore"); + qApp_moduledicts[1] = coreDict; + } + if (qApp != nullptr && coreDict != nullptr && coreDict != Py_None) { PyObject *coreApp = PyDict_GetItemString(coreDict, "QCoreApplication"); if (coreApp != nullptr) { qApp_content = PyObject_CallMethod(coreApp, "instance", ""); -- cgit v1.2.3 From c0ce6747df8a28ebab37a2ef5cda7d0db4e51793 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 22 Dec 2019 17:38:00 +0100 Subject: qApp: make sure to create the right instance when embedding qApp has special treatment for the embedded case where some Q*Application instance might exist before initialization happens. In order to get these cases right, it was necessary to try to import all three modules in question and do the initialization with the highest existing module index. Change-Id: Ifd27129ce166dee20e9424b1ee04a0d66cba79cc Fixes: PYSIDE-1164 Task-number: PYSIDE-1135 Reviewed-by: Friedemann Kleint Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/libshiboken/qapp_macro.cpp | 70 +++++++++++++++++++--------- 1 file changed, 47 insertions(+), 23 deletions(-) (limited to 'sources') diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp index c2018bd6f..f92cc7087 100644 --- a/sources/shiboken2/libshiboken/qapp_macro.cpp +++ b/sources/shiboken2/libshiboken/qapp_macro.cpp @@ -53,19 +53,17 @@ extern "C" // variable that monitors Q*Application.instance(). // This variable is also able to destroy the app by deleting qApp. // +static const char *mod_names[3] = {"PySide2.QtCore", "PySide2.QtGui", "PySide2.QtWidgets"}; +static const char *app_names[3] = {"QCoreApplication", "QGuiApplication", "QApplication"}; + static int qApp_module_index(PyObject *module) { const char *name = PyModule_GetName(module); - int ret = 0; - - if (strcmp(name, "PySide2.QtCore") == 0) - ret = 1; - else if (strcmp(name, "PySide2.QtGui") == 0) - ret = 2; - else if (strcmp(name, "PySide2.QtWidgets") == 0) - ret = 3; - return ret; + for (int idx = 0; idx < 3; idx++) + if (strcmp(name, mod_names[idx]) == 0) + return idx + 1; + return 0; } #define PYTHON_IS_PYTHON3 (PY_VERSION_HEX >= 0x03000000) @@ -109,6 +107,8 @@ reset_qApp_var(void) return 0; } +static bool app_created = false; + /* * Note: * The PYSIDE-585 problem was that shutdown is called one more often @@ -120,7 +120,6 @@ reset_qApp_var(void) PyObject * MakeSingletonQAppWrapper(PyTypeObject *type) { - static bool app_created = false; if (type == nullptr) type = Py_NONE_TYPE; if (!(type == Py_NONE_TYPE || Py_TYPE(qApp_content) == Py_NONE_TYPE)) { @@ -245,20 +244,45 @@ NotifyModuleForQApp(PyObject *module, void *qApp) * Therefore, the implementation is very simple and just redirects the * qApp_contents variable and assigns the instance, instead of vice-versa. */ - PyObject *coreDict = qApp_moduledicts[1]; - if (coreDict == nullptr) { - // PYSIDE-1135: Make sure that at least QtCore gets imported. - // That problem exists when a derived instance is created in C++. - qApp_moduledicts[1] = Py_None; // anything != nullptr during import - coreDict = PyImport_ImportModule("PySide2.QtCore"); - qApp_moduledicts[1] = coreDict; - } - if (qApp != nullptr && coreDict != nullptr && coreDict != Py_None) { - PyObject *coreApp = PyDict_GetItemString(coreDict, "QCoreApplication"); - if (coreApp != nullptr) { - qApp_content = PyObject_CallMethod(coreApp, "instance", ""); - reset_qApp_var(); + + // PYSIDE-1135: Make sure that at least QtCore gets imported. + // That problem exists when a derived instance is created in C++. + // PYSIDE-1164: Use the highest Q*Application module possible, + // because in embedded mode the instance() seems to be sticky. + static bool oneshot_active = false; + if (qApp == nullptr || app_created || oneshot_active) + return; + + // qApp exists without an application created. + // We assume that we are embedded, and we simply try to import all three modules. + oneshot_active = true; + int mod_found = 0; + const char *mod_name, *app_name; + const char *thismod_name = PyModule_GetName(module); + + // First go through all three modules, import and set qApp_moduledicts. + for (int idx = 0; idx < 3; idx++) { + // only import if it is not already the module + PyObject *mod = strcmp(thismod_name, mod_names[idx]) == 0 ? module + : PyImport_ImportModule(mod_names[idx]); + if (mod != nullptr) { + mod_found = idx + 1; + qApp_moduledicts[mod_found] = PyModule_GetDict(mod); + mod_name = PyModule_GetName(mod); + app_name = app_names[idx]; + continue; } + PyErr_Clear(); + } + + // Then take the highest module and call instance() on it. + if (mod_found) { + PyObject *mod_dict = qApp_moduledicts[mod_found]; + PyObject *app_class = PyDict_GetItemString(mod_dict, app_name); + qApp_content = PyObject_CallMethod(app_class, const_cast("instance"), + const_cast("")); + app_created = true; + reset_qApp_var(); } } -- cgit v1.2.3 From 783b1e3fdde98ad4da6c5576728d7b047e8d6219 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Thu, 7 Nov 2019 11:53:08 +0100 Subject: docs: Propose new structure for API index Change-Id: If2d96afbf93f153fb1b8e79f150a934620899d18 Reviewed-by: Friedemann Kleint --- sources/pyside2/doc/api.rst | 94 ++++++++++++++++++++++++++----------------- sources/pyside2/doc/index.rst | 2 +- 2 files changed, 59 insertions(+), 37 deletions(-) (limited to 'sources') diff --git a/sources/pyside2/doc/api.rst b/sources/pyside2/doc/api.rst index 2cc258c75..337d383b4 100644 --- a/sources/pyside2/doc/api.rst +++ b/sources/pyside2/doc/api.rst @@ -5,64 +5,86 @@ Basic modules ------------- - These are the main modules that will help you build a Widget based UI. - :mod:`Qt Core ` - Provides core non-GUI functionality, like signal and slots, properties, base classes of item models, serialization, etc. - :mod:`Qt GUI ` - Extends QtCore with GUI functionality: Events, windows and screens, OpenGL and raster-based 2D painting, images. - :mod:`Qt Widgets ` - Ready to use Widgets for your application, including also graphical elements for your UI. +These are the main modules that help you build a Widget-based UI. + ++---------------------------------------+--------------------------------------------------------+ +| :mod:`Qt Core ` | Provides core non-GUI functionality, like signal and | +| | slots, properties, base classes of item models, | +| | serialization, and more. | ++---------------------------------------+--------------------------------------------------------+ +| :mod:`Qt GUI ` | Extends QtCore with GUI functionality: Events, windows | +| | and screens, OpenGL and raster-based 2D painting, as | +| | well as images. | ++---------------------------------------+--------------------------------------------------------+ +| :mod:`Qt Widgets ` | Provides ready to use Widgets for your application, | +| | including graphical elements for your UI. | ++---------------------------------------+--------------------------------------------------------+ QML and Qt Quick ---------------- - If you want to use the `QML Language `, these - modules will help you interact with it from Python. - :mod:`Qt QML ` - Base Python API to interact with the QML module. - :mod:`Qt Quick ` - Provides classes for embedding Qt Quick in Qt applications. - :mod:`Qt QuickWidgets ` - Provides the QQuickWidget class for embedding Qt Quick in widget-based applications. +Use these modules to interact with the `QML Language `, +from Python. + ++-------------------------------------------------+----------------------------------------------+ +| :mod:`Qt QML ` | The base Python API to interact with the | +| | module. | ++-------------------------------------------------+----------------------------------------------+ +| :mod:`Qt Quick ` | Provides classes to embed Qt Quick in Qt | +| | applications. | ++-------------------------------------------------+----------------------------------------------+ +| :mod:`Qt QuickWidgets ` | Provides the QQuickWidget class to embed Qt | +| | Quick in widget-based applications. | ++-------------------------------------------------+----------------------------------------------+ Data visualization ------------------ - Charts and diagrams: these modules provide a large amount - of classes that can help you include these elements in your UI. +Charts, diagrams, animations: these modules provide classes to help you include these elements in +your UI. - :mod:`Qt Charts ` - Provides a set of easy to use chart components. - :mod:`Qt DataVisualization ` - Provides a way to visualize data in 3D as bar, scatter, and surface graphs. ++------------------------------------------------------------+-----------------------------------+ +| :mod:`Qt Charts ` | Provides a set of easy to use | +| | chart components. | ++------------------------------------------------------------+-----------------------------------+ +| :mod:`Qt DataVisualization ` | Provides a way to visualize data | +| | in 3D as bar, scatter, or surface | +| | graphs. | ++------------------------------------------------------------+-----------------------------------+ Multimedia ----------- - Audio, video, and hardware interaction: check these modules if you are - looking for multimedia solutions. +Audio, video, and hardware interaction: use these modules for multimedia solutions. - :mod:`Qt Multimedia ` - Provides low-level multimedia functionality. - :mod:`Qt MultimediaWidgets ` - Provides the widget-based multimedia API. ++------------------------------------------------------------+-----------------------------------+ +| :mod:`Qt Multimedia ` | Provides low-level multimedia | +| | functionality. | ++------------------------------------------------------------+-----------------------------------+ +| :mod:`Qt MultimediaWidgets ` | Provides the widget-based | +| | multimedia API. | ++------------------------------------------------------------+-----------------------------------+ WebEngine --------- - If your project is based on a browser or the features around web - based applications, these modules will help you to interact with them. +If your project is based on a browser or the features around Web-based applications, use these +modules to interact with them. - :mod:`Qt WebEngineWidgets ` - Provides widgets that can handle web content. - :mod:`Qt WebChannel ` - Enables peer-to-peer communication between a server and a client - (HTML/JavaScript or QML application). ++---------------------------------------------------------+--------------------------------------+ +| :mod:`Qt WebEngineWidgets ` | Provides widgets to handle Web | +| | content. | ++---------------------------------------------------------+--------------------------------------+ +| :mod:`Qt WebChannel ` | Enables peer-to-peer communication | +| | between a server and a client | +| | (HTML/JavaScript or QML application).| ++---------------------------------------------------------+--------------------------------------+ All the modules --------------- - Here is a complete list of modules supported by |pymodname|. +There are many other modules currently supported by |pymodname|, here you can find a complete list +of them. - :doc:`Modules ` + :doc:`Check all the modules ` diff --git a/sources/pyside2/doc/index.rst b/sources/pyside2/doc/index.rst index 93e3451c5..96cbf2ab2 100644 --- a/sources/pyside2/doc/index.rst +++ b/sources/pyside2/doc/index.rst @@ -2,7 +2,7 @@ ********* **Qt for Python** offers the official Python bindings for `Qt`_ (`PySide2`_), -enabling the use of its APIs in Python applications, and a binding generator tool (`Shiboken2`_) +so that you can use Qt5 APIs in your Python applications, and a binding generator tool (`Shiboken2`_) which can be used to expose C++ projects into Python. |project| is available under the LGPLv3/GPLv3 and the Qt commercial license. -- cgit v1.2.3 From df7c519dc5677134badd5a1cd1d2fe6b1f0b4573 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Fri, 3 Jan 2020 16:14:36 +0100 Subject: Doc: Update toctree to include only the module index The index adds all the class reference docs to the toctree so we don't need to include everything under the module directory. Change-Id: I6ef20914a63a1f246b06b2725435a4fc42deaf9b Reviewed-by: Friedemann Kleint Reviewed-by: Paul Wicking --- sources/pyside2/doc/modules.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sources') diff --git a/sources/pyside2/doc/modules.rst b/sources/pyside2/doc/modules.rst index d9accd664..bb4b112a1 100644 --- a/sources/pyside2/doc/modules.rst +++ b/sources/pyside2/doc/modules.rst @@ -5,7 +5,7 @@ Qt Modules :hidden: :glob: - PySide2/Qt*/* + PySide2/Qt*/index .. list-table:: :widths: 150, 150 -- cgit v1.2.3 From a936cf492407f5d675bbed74e58cf74b0a567090 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Mon, 23 Dec 2019 15:59:18 +0100 Subject: Shiboken: QtDoc: Change the order of entries at the beginning In the class reference RSTs, the label entry must appear at first before the current module entry. In addition, there must be at least two empty lines before the page title. Otherwise, the module's index page drops out of the toctree, resulting in incomplete navigation breadcrumb. Change-Id: I65a35b0bb9f2946fb5d45b1d1b8a453c20745e79 Reviewed-by: Paul Wicking Reviewed-by: Friedemann Kleint --- sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sources') diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index 9c9a2ff1e..791d9faea 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -1622,9 +1622,9 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex m_docParser->setPackageName(metaClass->package()); m_docParser->fillDocumentation(const_cast(metaClass)); - s << ".. currentmodule:: " << metaClass->package() << endl; QString className = getClassTargetFullName(metaClass, false); - s << ".. _" << className << ":" << endl << endl; + s << ".. _" << className << ":" << "\n\n"; + s << ".. currentmodule:: " << metaClass->package() << "\n\n\n"; s << className << endl; s << Pad('*', className.count()) << endl << endl; -- cgit v1.2.3 From 6534335da7d386d27d14cdc8a0198702f9229555 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sun, 5 Jan 2020 15:53:22 +0100 Subject: Fix Limited API for Python 3.8 This trivial patch fixes an omission that has not been caught in earlier versions: PyObject_INIT must be replaced by PyObject_Init I think this change came by chance and was not the primary intent of the authors. Otherwise they would have made sure that the PyObject_INIT macro does not even exist when the Limited API is enabled. Change-Id: Iee8127dd398f1ec0997b9a629c5c48076137cecf Reviewed-by: Friedemann Kleint --- sources/shiboken2/libshiboken/qapp_macro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sources') diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp index f92cc7087..827c240c5 100644 --- a/sources/shiboken2/libshiboken/qapp_macro.cpp +++ b/sources/shiboken2/libshiboken/qapp_macro.cpp @@ -162,7 +162,7 @@ MakeSingletonQAppWrapper(PyTypeObject *type) if (__moduleShutdown != nullptr) Py_XDECREF(PyObject_CallFunction(__moduleShutdown, const_cast("()"))); } else { - PyObject_INIT(qApp_content, type); + PyObject_Init(qApp_content, type); app_created = true; } Py_INCREF(qApp_content); -- cgit v1.2.3