tecla-keyboard-layout-viewer/tecla-handle-TeclaModel-constructor-returning-NULL.patch

35 lines
1.5 KiB
Diff

commit 931112aec0ba5a626327d8cb490b0b86e4c0b55c
Author: Carlos Garnacho <carlosg@gnome.org>
Date: Thu Sep 21 13:23:00 2023 +0200
application: Handle TeclaModel constructor possibly returning NULL
This might be the case if an unknown keymap name is passed as a
commandline argument. We ATM just show a window with empty keys,
so there's room for improvement in the future (e.g. state that
the keymap does not exist).
diff -Nura tecla-45.0/src/tecla-application.c tecla-45.0_new/src/tecla-application.c
--- tecla-45.0/src/tecla-application.c 2023-09-17 01:02:57.000000000 +0800
+++ tecla-45.0_new/src/tecla-application.c 2024-03-31 16:28:22.603133598 +0800
@@ -375,11 +375,14 @@
if (tecla_app->layout) {
tecla_app->main_model =
tecla_model_new_from_layout_name (tecla_app->layout);
- connect_model (tecla_app->main_window,
- tecla_app->main_view,
- tecla_app->main_model);
- g_clear_pointer (&tecla_app->layout, g_free);
- update_title (tecla_app->main_window, tecla_app->main_model);
+
+ if (tecla_app->main_model) {
+ connect_model (tecla_app->main_window,
+ tecla_app->main_view,
+ tecla_app->main_model);
+ g_clear_pointer (&tecla_app->layout, g_free);
+ update_title (tecla_app->main_window, tecla_app->main_model);
+ }
}
gtk_window_present (tecla_app->main_window);