diff options
author | Martin Negyokru <negyokru@inf.u-szeged.hu> | 2022-12-23 13:18:28 +0100 |
---|---|---|
committer | Martin Negyokru <negyokru@inf.u-szeged.hu> | 2023-01-09 10:10:29 +0100 |
commit | 1da0407a3440b89a8a4500e3a5c568c949d563b3 (patch) | |
tree | 9a5f772572f8071f80e29158dd690bf8e3aec29c | |
parent | acae09d86295ed711ce6c8eca28a399f71af8869 (diff) |
Fix crash when /usr/share/X11/xkb is empty
Fallback to Stub implementation instead of crashing.
Pick-to: 6.5
Task-number: QTBUG-105124
Change-Id: I7ad41daefe279b33bf924c74ee90e7d6a2375a63
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | src/core/ozone/ozone_platform_qt.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/ozone/ozone_platform_qt.cpp b/src/core/ozone/ozone_platform_qt.cpp index c4929295e..5b7e9b4d7 100644 --- a/src/core/ozone/ozone_platform_qt.cpp +++ b/src/core/ozone/ozone_platform_qt.cpp @@ -25,11 +25,13 @@ #include "platform_window_qt.h" #if BUILDFLAG(USE_XKBCOMMON) +#include "base/logging.h" #include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h" #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" #include <X11/XKBlib.h> #include <X11/extensions/XKBrules.h> +#include <filesystem> extern void *GetQtXDisplay(); #endif // BUILDFLAG(USE_XKBCOMMON) @@ -181,8 +183,10 @@ static std::string getCurrentKeyboardLayout() bool OzonePlatformQt::InitializeUI(const ui::OzonePlatform::InitParams &) { #if BUILDFLAG(USE_XKBCOMMON) + std::string xkb_path("/usr/share/X11/xkb"); std::string layout = getCurrentKeyboardLayout(); - if (layout.empty()) { + if (layout.empty() || !std::filesystem::exists(xkb_path) || std::filesystem::is_empty(xkb_path)) { + LOG(WARNING) << "Failed to load keymap file, falling back to StubKeyboardLayoutEngine"; m_keyboardLayoutEngine = std::make_unique<StubKeyboardLayoutEngine>(); } else { m_keyboardLayoutEngine = std::make_unique<XkbKeyboardLayoutEngine>(m_xkbEvdevCodeConverter); |