From 1adb18fc3166ee4bd15bf4921b1f11ae44f62d03 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 May 2021 15:56:17 +0200 Subject: PySide6/QtGui: Fix crashes in functions returning internally owned classes by pointer Indicate Default ownership, for QClipboard.mimeData(), QTextCursor.currentList(), QTextCursor.currentTable(), fixing: RuntimeError: Internal C++ object (PySide6.QtCore.QMimeData) already deleted. RuntimeError: Internal C++ object (PySide6.QtGui.QTextList) already deleted. [ChangeLog][PySide6] Crashes in QClipboard.mimeData(), QTextCursor.currentList() and QTextCursor.currentTable() have been fixed. Change-Id: I1e4f55856bce8bf951edd8579331f0242e904ae6 Reviewed-by: Christian Tismer (cherry picked from commit 8cd50636102be2e1178c8c602a3e374891398e3e) --- sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml index b0c61fe64..54f18e133 100644 --- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml +++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml @@ -643,6 +643,16 @@ + + + + + + + + + + @@ -1760,6 +1770,11 @@ + + + + + -- cgit v1.2.3 From 0eb2cde3fee7e3cdc2e1273001ae532c499680e5 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Sat, 1 May 2021 14:47:05 +0200 Subject: __feature__: Ensure that features are not affected by other imports Imports should not touch the feature dict unless they are feature imports. This was a small error in the import logic. (also fixed a const_cast glitch) Change-Id: I16045fffb4b770861ff2efba674667894e0798e5 Fixes: PYSIDE-1548 Reviewed-by: Friedemann Kleint (cherry picked from commit 39ba36db0fb8a3c722cb23e02f38abab9c67592c) Reviewed-by: Qt CI Bot Reviewed-by: Christian Tismer --- sources/pyside2/tests/QtCore/snake_prop_feature_test.py | 2 ++ sources/shiboken2/libshiboken/signature/signature.cpp | 2 +- .../shibokenmodule/files.dir/shibokensupport/feature.py | 11 ++++------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sources/pyside2/tests/QtCore/snake_prop_feature_test.py b/sources/pyside2/tests/QtCore/snake_prop_feature_test.py index 779b8a408..aea6a22ab 100644 --- a/sources/pyside2/tests/QtCore/snake_prop_feature_test.py +++ b/sources/pyside2/tests/QtCore/snake_prop_feature_test.py @@ -88,6 +88,8 @@ class FeatureTest(unittest.TestCase): window.modal from __feature__ import snake_case, true_property + #PYSIDE-1548: Make sure that another import does not clear the features. + import sys self.assertTrue(isinstance(QtWidgets.QWidget.modal, property)) self.assertTrue(isinstance(window.modal, bool)) diff --git a/sources/shiboken2/libshiboken/signature/signature.cpp b/sources/shiboken2/libshiboken/signature/signature.cpp index 8cda6f810..6880ea1f2 100644 --- a/sources/shiboken2/libshiboken/signature/signature.cpp +++ b/sources/shiboken2/libshiboken/signature/signature.cpp @@ -436,7 +436,7 @@ static PyObject *adjustFuncName(const char *func_name) * Note that fget is impossible because there are no parameters. */ static const char mapping_name[] = "shibokensupport.signature.mapping"; - static PyObject *sys_modules = PySys_GetObject("modules"); + static PyObject *sys_modules = PySys_GetObject(const_cast("modules")); static PyObject *mapping = PyDict_GetItemString(sys_modules, mapping_name); static PyObject *ns = PyModule_GetDict(mapping); diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py index fe3491f9e..8bd8856ff 100644 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py +++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py @@ -114,13 +114,10 @@ def _import(name, *args, **kwargs): sys.modules["PySide2.QtCore"].__init_feature__() return sys.modules["__feature__"] - if name.split(".")[0] == "PySide2": - # This is a module that imports PySide2. - flag = existing if isinstance(existing, int) else 0 - else: - # This is some other module. Ignore it in switching. - flag = -1 - pyside_feature_dict[importing_module] = flag + if importing_module not in pyside_feature_dict: + # Ignore new modules if not from PySide. + default = 0 if name.split(".")[0] == "PySide2" else -1 + pyside_feature_dict[importing_module] = default return original_import(name, *args, **kwargs) _is_initialized = False -- cgit v1.2.3 From 2b885c0fa6148b96ec88c0f6720bdffd5b4f2ef5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 25 May 2021 10:34:31 +0200 Subject: Revert "Fix crashes when using the QImage(uchar *) data constructors" It breaks a use case in pyqtgraph, which expects to be able to manipulate the image by modifying the data. This reverts commit cc011c8980cc4ce02e3d9cceb74ee028c204214e. The helper Shiboken::Buffer::copyData() is left in place since it can be useful for other cases. Task-number: PYSIDE-1563 Change-Id: Ib0d58662a4257a315865436a32e99d9ee6369e03 Reviewed-by: Christian Tismer (cherry picked from commit 4daaa2edd881865172f19c007c69113bf4afc8cd) --- sources/pyside2/PySide2/templates/gui_common.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/pyside2/PySide2/templates/gui_common.xml b/sources/pyside2/PySide2/templates/gui_common.xml index 16116877f..a139a5fe9 100644 --- a/sources/pyside2/PySide2/templates/gui_common.xml +++ b/sources/pyside2/PySide2/templates/gui_common.xml @@ -80,8 +80,8 @@