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
This commit is contained in:
wmayer
2025-03-14 16:31:27 +01:00
committed by Ladislav Michl
parent a0899cc65d
commit da6bafe246

View File

@@ -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<QKeySequence::StandardKey>(sk);
QKeySequence ks(type);