Issue 1029 - Crash on QTreeViewItem#setBackgroundColor (#1032)

* Fixed issue #1029

The problem happened because in the described case the
tl::Variant used as a intermediate container holds the
Python QBrush object and when it gets deleted, the
QBrush object is deleted too.

* Added tests
This commit is contained in:
Matthias Köfferlein
2022-03-16 23:27:25 +01:00
committed by GitHub
parent 6d0aa9c435
commit 51cf918f56
4 changed files with 39 additions and 6 deletions
+9
View File
@@ -640,6 +640,15 @@ class QtBindingTest(unittest.TestCase):
else:
self.assertEqual(str(jsonData), 'b\'{"test":"test"}\'')
def test_54(self):
# issue #1029 (Crash for QBrush passed to setData)
item = pya.QTreeWidgetItem()
item.setBackground(0, pya.QBrush(pya.QColor(0xFF, 0xFF, 0x00)))
self.assertEqual(item.background(0).color.red, 255)
self.assertEqual(item.background(0).color.green, 255)
self.assertEqual(item.background(0).color.blue, 0)
# run unit tests
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(QtBindingTest)