From d6a62e4fa4b3d16381d740c1215c87a419a845d9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 14 Mar 2025 16:31:27 +0100 Subject: [PATCH] Gui: Fix crash in Command::keySequenceToAccel If FreeCAD is loaded without GUI it isn't allowed to access the QKeySequence class as it will cause a crash. So, it checks beforehand if QApplication::instance() is null. This fixes issue 16407 --- src/Gui/Command.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 9bf7ef88c1..0bc31de89c 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -899,8 +899,14 @@ const char* Command::keySequenceToAccel(int sk) const static StringMap strings; auto i = strings.find(sk); - if (i != strings.end()) + if (i != strings.end()) { return i->second.c_str(); + } + + // In case FreeCAD is loaded without GUI (issue 16407) + if (!QApplication::instance()) { + return ""; + } auto type = static_cast(sk); QKeySequence ks(type);