diff options
-rw-r--r-- | sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml | 3 | ||||
-rw-r--r-- | sources/pyside2/PySide2/glue/qtwidgets.cpp | 8 | ||||
-rw-r--r-- | sources/pyside2/tests/QtWidgets/qstyle_test.py | 8 |
3 files changed, 19 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index 8d732d908..c7fae8d7f 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -2956,6 +2956,9 @@ <add-function signature="QApplication()"> <inject-code file="../glue/qtwidgets.cpp" snippet="qapplication-2"/> </add-function> + <modify-function signature="setStyle(QStyle*)"> + <inject-code class="target" position="end" file="../glue/qtwidgets.cpp" snippet="qapplication-setStyle"/> + </modify-function> <modify-function signature="exec()" rename="exec_" allow-thread="yes"/> <inject-code class="native" file="glue/qapplication_init.cpp" position="beginning"/> </object-type> diff --git a/sources/pyside2/PySide2/glue/qtwidgets.cpp b/sources/pyside2/PySide2/glue/qtwidgets.cpp index f0e446f62..02e74c997 100644 --- a/sources/pyside2/PySide2/glue/qtwidgets.cpp +++ b/sources/pyside2/PySide2/glue/qtwidgets.cpp @@ -266,6 +266,14 @@ if (myStyle && qApp) { } // @snippet qwidget-style +// @snippet qapplication-setStyle +if (qApp) { + Shiboken::AutoDecRef pyApp(%CONVERTTOPYTHON[QApplication*](qApp)); + Shiboken::Object::setParent(pyApp, %PYARG_1); + Shiboken::Object::releaseOwnership(%PYARG_1); +} +// @snippet qapplication-setStyle + // @snippet qwidget-setlayout qwidgetSetLayout(%CPPSELF, %1); // %FUNCTION_NAME() - disable generation of function call. diff --git a/sources/pyside2/tests/QtWidgets/qstyle_test.py b/sources/pyside2/tests/QtWidgets/qstyle_test.py index eb2a73d29..1dcce2737 100644 --- a/sources/pyside2/tests/QtWidgets/qstyle_test.py +++ b/sources/pyside2/tests/QtWidgets/qstyle_test.py @@ -26,6 +26,7 @@ ## ############################################################################# +import sys import unittest from helper import UsesQApplication @@ -78,6 +79,13 @@ class SetStyleTest(UsesQApplication): QApplication.instance().processEvents() self.assertTrue(proxyStyle.polished > 0) + def testSetStyleOwnership(self): + style = QStyleFactory.create(QStyleFactory.keys()[0]) + self.assertEqual(sys.getrefcount(style), 2) + QApplication.instance().setStyle(style) + self.assertEqual(sys.getrefcount(style), 3) + + if __name__ == '__main__': unittest.main() |