tst_QDockWidget: use local context for timer
If we use 'this' as context it might still try to invoke the timer after we have left the function, leading to stack-use-after-return. To avoid doing an in-depth dive if it's okay to use mainWindow as the context or not, I just added a new local QObject. Amends 9ff40b59da58160dc26c54204a615a2456e07405 Pick-to: 6.5 Change-Id: I2c3bdc1eb06731d9c38979610303876c2748fb73 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 26ded9dedf3f35e93b81bd0281fdd0bd30acb9d4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f514fba45b
commit
ed5bc72f76
@ -1529,6 +1529,7 @@ void tst_QDockWidget::closeAndDelete()
|
|||||||
QSKIP("Test skipped on Wayland.");
|
QSKIP("Test skipped on Wayland.");
|
||||||
#ifdef QT_BUILD_INTERNAL
|
#ifdef QT_BUILD_INTERNAL
|
||||||
// Create a mainwindow with a central widget and two dock widgets
|
// Create a mainwindow with a central widget and two dock widgets
|
||||||
|
QObject localContext;
|
||||||
QPointer<QDockWidget> d1;
|
QPointer<QDockWidget> d1;
|
||||||
QPointer<QDockWidget> d2;
|
QPointer<QDockWidget> d2;
|
||||||
QPointer<QWidget> cent;
|
QPointer<QWidget> cent;
|
||||||
@ -1555,7 +1556,7 @@ void tst_QDockWidget::closeAndDelete()
|
|||||||
|
|
||||||
// Close everything with a single shot. Expected behavior: Event loop stops
|
// Close everything with a single shot. Expected behavior: Event loop stops
|
||||||
bool eventLoopStopped = true;
|
bool eventLoopStopped = true;
|
||||||
QTimer::singleShot(0, this, [mainWindow, d1, d2] {
|
QTimer::singleShot(0, &localContext, [mainWindow, d1, d2] {
|
||||||
mainWindow->close();
|
mainWindow->close();
|
||||||
QTRY_VERIFY(!mainWindow->isVisible());
|
QTRY_VERIFY(!mainWindow->isVisible());
|
||||||
QTRY_VERIFY(d1->isVisible());
|
QTRY_VERIFY(d1->isVisible());
|
||||||
@ -1567,7 +1568,7 @@ void tst_QDockWidget::closeAndDelete()
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Fallback timer to report event loop still running
|
// Fallback timer to report event loop still running
|
||||||
QTimer::singleShot(100, this, [&eventLoopStopped] {
|
QTimer::singleShot(100, &localContext, [&eventLoopStopped] {
|
||||||
qCDebug(lcTestDockWidget) << "Last dock widget hasn't shout down event loop!";
|
qCDebug(lcTestDockWidget) << "Last dock widget hasn't shout down event loop!";
|
||||||
eventLoopStopped = false;
|
eventLoopStopped = false;
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user