39 lines
1.4 KiB
Diff
39 lines
1.4 KiB
Diff
commit d6760195ab13d29bce1c6590638e4200cd6632f2 (HEAD -> d6760195ab13d29bce1c6590638e4200cd6632f2)
|
|
Author: Carlos Garnacho <carlosg@gnome.org>
|
|
Date: Thu Sep 21 13:24:58 2023 +0200
|
|
|
|
model: Return NULL if no xkb_keymap could be created
|
|
|
|
Right now we are somewhat optimistic that the passed keymap
|
|
name does exist, triggering crashes if it does not. Make
|
|
TeclaModel constructors return NULL if XKB does not know
|
|
about the given name/variant.
|
|
|
|
Closes: https://gitlab.gnome.org/GNOME/tecla/-/issues/16
|
|
|
|
diff -Nura tecla-45.0/src/tecla-model.c tecla-45.0_new/src/tecla-model.c
|
|
--- tecla-45.0/src/tecla-model.c 2023-09-17 01:02:57.000000000 +0800
|
|
+++ tecla-45.0_new/src/tecla-model.c 2024-03-31 16:46:54.193944659 +0800
|
|
@@ -299,7 +299,7 @@
|
|
TeclaModel *
|
|
tecla_model_new_from_layout_name (const gchar *name)
|
|
{
|
|
- TeclaModel *model;
|
|
+ TeclaModel *model = NULL;
|
|
struct xkb_context *xkb_context;
|
|
struct xkb_keymap *xkb_keymap;
|
|
g_autofree gchar *layout = NULL;
|
|
@@ -325,8 +325,10 @@
|
|
xkb_keymap = xkb_keymap_new_from_names (xkb_context, &rule_names, 0);
|
|
xkb_context_unref (xkb_context);
|
|
|
|
- model = tecla_model_new_from_xkb_keymap (xkb_keymap);
|
|
- xkb_keymap_unref (xkb_keymap);
|
|
+ if (xkb_keymap) {
|
|
+ model = tecla_model_new_from_xkb_keymap (xkb_keymap);
|
|
+ xkb_keymap_unref (xkb_keymap);
|
|
+ }
|
|
|
|
return model;
|
|
}
|