diff options
author | Stefan Eichenberger <stefan.eichenberger@toradex.com> | 2022-11-16 17:42:02 +0100 |
---|---|---|
committer | Stefan Eichenberger <eichest@gmail.com> | 2022-11-18 10:28:11 +0100 |
commit | 2ca50c7c93e69cd02028ec5a204b84632d996703 (patch) | |
tree | 3049f3977f3a4fc30a4199fd53a3b26d4e6858c9 | |
parent | 52d406296e885719b0d8e0209b454da74957a67e (diff) |
qt5: examples: cinematicexperience: Fix a crash with no screen
When there is no screen attached the Qt application fails to start.
The message when the application crashes is:
xdg_wm_base@17: error 4: xdg_surface geometry (500 x 500) is larger than the configured fullscreen state (0 x 0)
The Wayland connection experienced a fatal error: Protocol error
This leads to a kernel messages each time the application tries to
start. With BSP5 the application just tries to restart every time the
applications exits but doesn't spam the kernel log. The reason
why this changed is this new feature:
https://code.qt.io/cgit/qt/qtwayland.git/commit/?h=5.15&id=d58008c4310f99d0faebcfb2fd9aa9296b813ecf
The change of this commit fixes the application so that it properly
works with no screen attached and doesn't crash at all.
Related-to: ELB-4884
Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
-rw-r--r-- | qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch | 43 | ||||
-rw-r--r-- | qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch b/qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch new file mode 100644 index 0000000..a7a6846 --- /dev/null +++ b/qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch @@ -0,0 +1,43 @@ +--- main.cpp.orig 2022-11-16 15:25:11.221100107 +0100 ++++ main.cpp 2022-11-18 09:30:01.084064039 +0100 +@@ -1,5 +1,22 @@ + #include <QGuiApplication> + #include <QQuickView> ++#include <QScreen> ++ ++void setFullscreen(QQuickView *view, const QScreen *screen) ++{ ++ QSize screenSize = screen->size(); ++ /* If we set fullscreen and screen size is 0,0 the application crashes. ++ * Therefore, we only set fullscreen mode when the screen size is big enough. ++ * We have to set visible false before we change the window state, else it ++ * won't update correctly and we might have a title bar */ ++ if ((screenSize.height() > 1) && (screenSize.width() > 1)) { ++ view->setVisible(false); ++ view->setWindowStates(Qt::WindowFullScreen); ++ } ++ ++ /* We always need to set visible to true, else the window will not show up */ ++ view->setVisible(true); ++} + + int main(int argc, char* argv[]) + { +@@ -10,9 +27,15 @@ + + const QString lowerArgument = QString::fromLatin1(argv[1]).toLower(); + if (lowerArgument == QLatin1String("--fullscreen")) { +- view.showFullScreen(); +- } else { ++ QObject::connect(&view, &QQuickView::screenChanged, &app, [&view](QScreen *screen) { ++ setFullscreen(&view, screen); ++ }, Qt::DirectConnection); ++ ++ setFullscreen(&view, view.screen()); ++ } ++ else { + view.show(); + } ++ + return app.exec(); + } diff --git a/qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend b/qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend new file mode 100644 index 0000000..e4d42f4 --- /dev/null +++ b/qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append = " file://fix-fullscreen-mode.patch" |