From e89d5337ab2d7c5efc5b1eda67f44f9af7b1bff3 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Mon, 30 Jan 2023 16:33:54 +0100 Subject: Handle missing wayland display gracefully When the wayland socket didn't exist, the appman-launcher-qml would terminate with an abort. This could happen for instance inside a container when the socket file was not mapped. This has been mitigated to only show a critical error message in the am.runtime.qml logging category and exit gracefully (with an error return code). Change-Id: Id29d0e79e260726d1ffd9b940eac806b483b8a19 Reviewed-by: Robert Griebl (cherry picked from commit 61e91284ade4ba7548e84e6550934aff5bcf1ca2) Reviewed-by: Qt Cherry-pick Bot --- src/tools/launcher-qml/launcher-qml.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/launcher-qml/launcher-qml.cpp b/src/tools/launcher-qml/launcher-qml.cpp index 351ec7f8..8ca08bb7 100644 --- a/src/tools/launcher-qml/launcher-qml.cpp +++ b/src/tools/launcher-qml/launcher-qml.cpp @@ -98,6 +98,11 @@ int main(int argc, char *argv[]) Logging::initialize(); try { + const QString socket = QDir(qEnvironmentVariable("XDG_RUNTIME_DIR")) + .filePath(qEnvironmentVariable("WAYLAND_DISPLAY")); + if (!QFileInfo::exists(socket)) + throw Exception("Cannot start application: no wayland display - expected socket at: %1").arg(socket); + LauncherMain::initialize(); Application app(argc, argv); LauncherMain launcher; -- cgit v1.2.1