Skip to content

Commit 918cd72

Browse files
tests: Fix warning about QBackingStore::flush() being called without handle
Call qApp->quit() delayed from the paint event. This fixes crashes on macOS and warnings: QBackingStore::flush() called for QWidgetWindow(0x600003a22460, name="MyWidgetClassWindow") which does not have a handle. Pick-to: 6.8 Change-Id: I2e5d8aa1cfc36c4c247f681b4219f52c1a618737 Reviewed-by: Cristian Maureira-Fredes <[email protected]>
1 parent ba41ec2 commit 918cd72

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

build_history/blacklist.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737
# Open GL functions failures on macOS (2/2020)
3838
[QtQml::qqmlnetwork_test]
3939
linux ci # extended, see PyPy section below
40-
[QtWidgets::bug_750]
41-
darwin ci
42-
[QtWidgets::qpicture_test]
43-
darwin ci
4440
[QtAsyncio::qasyncio_test_chain]
4541
win32
4642
[QtQml::bug_825]

sources/pyside6/tests/QtWidgets/bug_750.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,28 @@
1313

1414
from helper.usesqapplication import UsesQApplication
1515

16-
from PySide6.QtCore import QTimer
16+
from PySide6.QtCore import QCoreApplication, QTimer
1717
from PySide6.QtGui import QPainter
1818
from PySide6.QtWidgets import QWidget
1919

2020

2121
class MyWidget(QWidget):
22+
def __init__(self):
23+
super().__init__()
24+
self._info = None
25+
2226
def paintEvent(self, e):
23-
p = QPainter(self)
24-
self._info = p.fontInfo()
25-
self._app.quit()
27+
with QPainter(self) as p:
28+
self._info = p.fontInfo()
29+
QTimer.singleShot(0, qApp.quit) # noqa: F821
2630

2731

2832
class TestQPainter(UsesQApplication):
2933
def testFontInfo(self):
3034
w = MyWidget()
31-
w._app = self.app
32-
w._info = None
33-
QTimer.singleShot(300, w.show)
35+
w.show()
36+
while not w.windowHandle().isExposed():
37+
QCoreApplication.processEvents()
3438
self.app.exec()
3539
self.assertTrue(w._info)
3640

sources/pyside6/tests/QtWidgets/qpicture_test.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
init_test_paths(False)
1313

1414
from helper.usesqapplication import UsesQApplication
15-
from PySide6.QtCore import QTimer
15+
from PySide6.QtCore import QCoreApplication, QTimer
1616
from PySide6.QtGui import QPicture, QPainter
1717
from PySide6.QtWidgets import QWidget
1818

1919

2020
class MyWidget(QWidget):
21+
def __init__(self, picture):
22+
super().__init__()
23+
self._picture = picture
24+
2125
def paintEvent(self, e):
2226
with QPainter(self) as p:
2327
p.drawPicture(0, 0, self._picture)
24-
self._app.quit()
28+
QTimer.singleShot(0, qApp.quit) # noqa: F821
2529

2630

2731
class QPictureTest(UsesQApplication):
@@ -36,11 +40,11 @@ def testFromData(self):
3640

3741
self.assertEqual(picture2.data(), picture.data())
3842

39-
w = MyWidget()
40-
w._picture = picture2
41-
w._app = self.app
43+
w = MyWidget(picture2)
4244

43-
QTimer.singleShot(300, w.show)
45+
w.show()
46+
while not w.windowHandle().isExposed():
47+
QCoreApplication.processEvents()
4448
self.app.exec()
4549

4650

0 commit comments

Comments
 (0)