1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
From: Colin Clark <colin.clark@cclark.uk>
Date: Sat, 7 Jun 2025 12:05:33 +0100
Subject: Fix #1768: Crash on "keyword autocomplete" command
https://github.com/BestImageViewer/geeqie/issues/1768
Check if the keywords pane has been initialized, and if not send an
application notification.
---
scripts/untranslated-text.sh | 1 +
src/bar-keywords.cc | 36 ++++++++++++++++++++++++++----------
src/bar.cc | 5 +++++
3 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/scripts/untranslated-text.sh b/scripts/untranslated-text.sh
index 2495047..be19e5a 100755
--- a/scripts/untranslated-text.sh
+++ b/scripts/untranslated-text.sh
@@ -195,6 +195,7 @@ format-fuji.cc
format-nikon.cc
format-olympus.cc
keymap-template.cc
+bar-keywords.cc
"
# A POSIX-compliant function that returns 0 if the substring is present, or 1
diff --git a/src/bar-keywords.cc b/src/bar-keywords.cc
index 49ff475..dd1f6b3 100644
--- a/src/bar-keywords.cc
+++ b/src/bar-keywords.cc
@@ -1950,25 +1950,41 @@ gboolean bar_keywords_autocomplete_focus(LayoutWindow *lw)
GtkWidget *pane;
GtkWidget *current_focus;
GList *children;
- gboolean ret;
+ gboolean ret = FALSE;
current_focus = gtk_window_get_focus(GTK_WINDOW(lw->window));
pane = bar_find_pane_by_id(lw->bar, PANE_KEYWORDS, "keywords");
- children = gtk_container_get_children(GTK_CONTAINER(pane));
-
- const GList *last_child = g_list_last(children);
- if (current_focus == last_child->data)
+ if (pane)
{
- ret = TRUE;
+ children = gtk_container_get_children(GTK_CONTAINER(pane));
+
+ const GList *last_child = g_list_last(children);
+ if (current_focus == last_child->data)
+ {
+ ret = TRUE;
+ }
+ else
+ {
+ gtk_widget_grab_focus(GTK_WIDGET(last_child->data));
+ ret = FALSE;
+ }
+
+ g_list_free(children);
}
else
{
- gtk_widget_grab_focus(GTK_WIDGET(last_child->data));
- ret = FALSE;
- }
+ GApplication *app = g_application_get_default();
- g_list_free(children);
+ g_autoptr(GNotification) notification = g_notification_new("Geeqie");
+
+ g_notification_set_title(notification, _("Keyword Autocomplete"));
+ g_notification_set_body(notification, _("The Info Sidebar has not yet been opened"));
+ g_notification_set_priority(notification, G_NOTIFICATION_PRIORITY_NORMAL);
+ g_notification_set_default_action(notification, "app.null");
+
+ g_application_send_notification(G_APPLICATION(app), "keyword-autocomplete-notification", notification);
+ }
return ret;
}
diff --git a/src/bar.cc b/src/bar.cc
index 1a5e4c7..654a557 100644
--- a/src/bar.cc
+++ b/src/bar.cc
@@ -575,6 +575,11 @@ GtkWidget *bar_find_pane_by_id(GtkWidget *bar, PaneType type, const gchar *id)
if (!id || !id[0]) return nullptr;
+ if (!bar)
+ {
+ return nullptr;
+ }
+
bd = static_cast<BarData *>(g_object_get_data(G_OBJECT(bar), "bar_data"));
if (!bd) return nullptr;
|