From 0e67fb41cfc4b4bfbaa7dc75f8ddebdf5a08e836 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 18 Mar 2021 11:24:10 +0100 Subject: Fix crash due to bad cast to QXcbScreen Fixes: QTBUG-91913 Change-Id: I498b8a18b7f47f94fd610f13797473951ea98f85 Reviewed-by: Liang Qi --- dependencies.yaml | 2 +- src/x11extras/qx11info_x11.cpp | 5 +++-- tests/auto/qx11info/tst_qx11info.cpp | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 0fda16c..45dace5 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -1,4 +1,4 @@ dependencies: ../qtbase: - ref: 130b2090147e0d28e35fd736fbefcd588c0014f6 + ref: 57f752b30a0f452e9cc079b5a4ede6134719a769 required: true diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp index ace0b6e..1ad1c75 100644 --- a/src/x11extras/qx11info_x11.cpp +++ b/src/x11extras/qx11info_x11.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -62,8 +63,8 @@ static QScreen *findScreenForVirtualDesktop(int virtualDesktopNumber) { const auto screens = QGuiApplication::screens(); for (QScreen *screen : screens) { - auto *qxcbScreen = dynamic_cast(screen); - if (qxcbScreen->virtualDesktopNumber() == virtualDesktopNumber) + auto *qxcbScreen = dynamic_cast(screen->handle()); + if (qxcbScreen && qxcbScreen->virtualDesktopNumber() == virtualDesktopNumber) return screen; } return nullptr; diff --git a/tests/auto/qx11info/tst_qx11info.cpp b/tests/auto/qx11info/tst_qx11info.cpp index b4207c1..36dd202 100644 --- a/tests/auto/qx11info/tst_qx11info.cpp +++ b/tests/auto/qx11info/tst_qx11info.cpp @@ -43,6 +43,7 @@ private slots: void isPlatformX11(); void appTime(); void peeker(); + void isCompositingManagerRunning(); }; void tst_QX11Info::staticFunctionsBeforeQApplication() @@ -374,6 +375,17 @@ void tst_QX11Info::peeker() QVERIFY(QTest::qWaitForWindowExposed(&test)); } +void tst_QX11Info::isCompositingManagerRunning() +{ + int argc = 0; + QGuiApplication app(argc, 0); + const bool b = QX11Info::isCompositingManagerRunning(); + Q_UNUSED(b); + const bool b2 = QX11Info::isCompositingManagerRunning(0); + Q_UNUSED(b2); + // just check that it didn't crash (QTBUG-91913) +} + QTEST_APPLESS_MAIN(tst_QX11Info) #include "tst_qx11info.moc" -- cgit v1.2.1