diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-03-12 11:11:10 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-03-14 12:04:59 +0100 |
commit | 918cd72f5eaebf56287a5ab0ac2e149ba1617a57 (patch) | |
tree | d97e00df118342ba564e9c1eba239f13bfd55ef6 /sources/pyside6/tests | |
parent | ba41ec2ec76c6af84a1ac42ff02f2fd518ab0db3 (diff) |
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 <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r-- | sources/pyside6/tests/QtWidgets/bug_750.py | 18 | ||||
-rw-r--r-- | sources/pyside6/tests/QtWidgets/qpicture_test.py | 16 |
2 files changed, 21 insertions, 13 deletions
diff --git a/sources/pyside6/tests/QtWidgets/bug_750.py b/sources/pyside6/tests/QtWidgets/bug_750.py index 074f569f6..61356c173 100644 --- a/sources/pyside6/tests/QtWidgets/bug_750.py +++ b/sources/pyside6/tests/QtWidgets/bug_750.py @@ -13,24 +13,28 @@ init_test_paths(False) from helper.usesqapplication import UsesQApplication -from PySide6.QtCore import QTimer +from PySide6.QtCore import QCoreApplication, QTimer from PySide6.QtGui import QPainter from PySide6.QtWidgets import QWidget class MyWidget(QWidget): + def __init__(self): + super().__init__() + self._info = None + def paintEvent(self, e): - p = QPainter(self) - self._info = p.fontInfo() - self._app.quit() + with QPainter(self) as p: + self._info = p.fontInfo() + QTimer.singleShot(0, qApp.quit) # noqa: F821 class TestQPainter(UsesQApplication): def testFontInfo(self): w = MyWidget() - w._app = self.app - w._info = None - QTimer.singleShot(300, w.show) + w.show() + while not w.windowHandle().isExposed(): + QCoreApplication.processEvents() self.app.exec() self.assertTrue(w._info) diff --git a/sources/pyside6/tests/QtWidgets/qpicture_test.py b/sources/pyside6/tests/QtWidgets/qpicture_test.py index 884f391a9..e9b0440c2 100644 --- a/sources/pyside6/tests/QtWidgets/qpicture_test.py +++ b/sources/pyside6/tests/QtWidgets/qpicture_test.py @@ -12,16 +12,20 @@ from init_paths import init_test_paths init_test_paths(False) from helper.usesqapplication import UsesQApplication -from PySide6.QtCore import QTimer +from PySide6.QtCore import QCoreApplication, QTimer from PySide6.QtGui import QPicture, QPainter from PySide6.QtWidgets import QWidget class MyWidget(QWidget): + def __init__(self, picture): + super().__init__() + self._picture = picture + def paintEvent(self, e): with QPainter(self) as p: p.drawPicture(0, 0, self._picture) - self._app.quit() + QTimer.singleShot(0, qApp.quit) # noqa: F821 class QPictureTest(UsesQApplication): @@ -36,11 +40,11 @@ class QPictureTest(UsesQApplication): self.assertEqual(picture2.data(), picture.data()) - w = MyWidget() - w._picture = picture2 - w._app = self.app + w = MyWidget(picture2) - QTimer.singleShot(300, w.show) + w.show() + while not w.windowHandle().isExposed(): + QCoreApplication.processEvents() self.app.exec() |