mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 04:49:12 -06:00
No longer trigger an assert when binding a key to an action that does not exist (closes #2485)
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/interaction/actionmanager.h>
|
||||
#include <openspace/interaction/keybindingmanager.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
@@ -69,6 +70,13 @@ std::vector<nlohmann::json> ShortcutTopic::shortcutsJson() const {
|
||||
global::keybindingManager->keyBindings();
|
||||
|
||||
for (const std::pair<const KeyWithModifier, std::string>& keyBinding : keyBindings) {
|
||||
if (!global::actionManager->hasAction(keyBinding.second)) {
|
||||
// We don't warn here as we don't know if the user didn't expect the action
|
||||
// to be there or not. They might have defined a keybind to do multiple things
|
||||
// only one of which is actually defined
|
||||
continue;
|
||||
}
|
||||
|
||||
const KeyWithModifier& k = keyBinding.first;
|
||||
// @TODO (abock, 2021-08-05) Probably this should be rewritten to better account
|
||||
// for the new action mechanism
|
||||
|
||||
@@ -55,11 +55,11 @@ void KeybindingManager::keyboardCallback(Key key, KeyModifier modifier, KeyActio
|
||||
auto ret = _keyLua.equal_range({ key, modifier });
|
||||
for (auto it = ret.first; it != ret.second; ++it) {
|
||||
ghoul_assert(!it->second.empty(), "Action must not be empty");
|
||||
ghoul_assert(
|
||||
global::actionManager->hasAction(it->second),
|
||||
"Action must be registered"
|
||||
);
|
||||
global::actionManager->triggerAction(it->second, ghoul::Dictionary());
|
||||
if (!global::actionManager->hasAction(it->second)) {
|
||||
// Silently ignoring the unknown action as the user might have intended to
|
||||
// bind a key to multiple actions, only one of which could be defined
|
||||
global::actionManager->triggerAction(it->second, ghoul::Dictionary());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user