mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-29 19:45:58 +01:00
keybinds: Only call fclose() when we have a valid file. (#2908)
Signed-off-by: Michael Pacheco <git@michaelpacheco.org>
This commit is contained in:
parent
cebab759d5
commit
ad3b8dddf9
1 changed files with 3 additions and 2 deletions
|
@ -141,10 +141,11 @@ void CKeybindManager::updateXKBTranslationState() {
|
||||||
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
|
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
|
||||||
|
|
||||||
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
FILE* const KEYMAPFILE = fopen(FILEPATH.c_str(), "r");
|
FILE* const KEYMAPFILE = FILEPATH == "" ? NULL : fopen(FILEPATH.c_str(), "r");
|
||||||
|
|
||||||
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) :
|
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) :
|
||||||
xkb_keymap_new_from_file(PCONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
xkb_keymap_new_from_file(PCONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
if (KEYMAPFILE)
|
||||||
fclose(KEYMAPFILE);
|
fclose(KEYMAPFILE);
|
||||||
|
|
||||||
if (!PKEYMAP) {
|
if (!PKEYMAP) {
|
||||||
|
|
Loading…
Reference in a new issue