From a5d4a71d32d1b2a095119351a0935c49f3ac0a50 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Tue, 27 Nov 2018 15:36:24 +0100 Subject: QApplication::setStyle ownership transfer Due to the nature of the qApp singleton, it was not enough to add the refcount of the style via the typesystem, as usual. An additional step of getting a reference to the qApp to set the parent of the style was required. A test case was included. Change-Id: I5e60983e961e7d3d310b1e1c2f6f9b80ee095308 Fixes: PYSIDE-861 Reviewed-by: Friedemann Kleint --- sources/pyside2/tests/QtWidgets/qstyle_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sources/pyside2/tests') 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() -- cgit v1.2.3