From 47a9729737965025ea3cfd87ff6c344ef587a933 Mon Sep 17 00:00:00 2001 From: deepend Date: Sun, 15 Feb 2026 15:23:39 -0700 Subject: [PATCH] =?UTF-8?q?Added=20a=20new=20session=20guard=20helper=20fo?= =?UTF-8?q?r=20the=20plugin=20GUI=20so=20addon=20commands=20only=20run=20w?= =?UTF-8?q?hen=20there=20is=20a=20valid=20active=20session,=20and=20emit?= =?UTF-8?q?=20a=20user-facing=20error=20otherwise.=20This=20prevents=20han?= =?UTF-8?q?dle=5Fcommand()=20calls=20with=20an=20invalid/null=20session=20?= =?UTF-8?q?context=20(a=20likely=20crash=20path=20on=20Windows=20in=20edge?= =?UTF-8?q?=20UI=20states).=20Updated=20plugin=20Unload=20and=20Reload=20c?= =?UTF-8?q?allbacks=20to=20use=20the=20guarded=20session=20helper=20before?= =?UTF-8?q?=20issuing=20command-based=20unload/reload=20for=20script=20plu?= =?UTF-8?q?gins,=20and=20to=20exit=20cleanly=20when=20no=20session=20is=20?= =?UTF-8?q?available.=20Fixed=20plugin=20list=20layout=20sizing=20by=20for?= =?UTF-8?q?cing=20the=20tree=20view=E2=80=99s=20scrolled=20container=20to?= =?UTF-8?q?=20expand/fill=20inside=20the=20plugin=20window=E2=80=99s=20vbo?= =?UTF-8?q?x,=20so=20the=20loaded-plugins=20list=20now=20uses=20full=20ava?= =?UTF-8?q?ilable=20height=20above=20the=20button=20row.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fe-gtk/plugingui.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index f41bcecb..5c9564ea 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -48,6 +48,16 @@ enum static GtkWidget *plugin_window = NULL; +static session * +plugingui_get_target_session (void) +{ + if (is_session (current_sess)) + return current_sess; + + fe_message (_("No active session available for addon command."), FE_MSG_ERROR); + return NULL; +} + #if HAVE_GTK3 #define ICON_PLUGIN_LOAD "document-open" #define ICON_PLUGIN_UNLOAD "edit-delete" @@ -218,6 +228,7 @@ static void plugingui_unload (GtkWidget * wid, gpointer unused) { char *modname, *file; + session *target_sess; GtkTreeView *view; GtkTreeIter iter; @@ -235,11 +246,19 @@ plugingui_unload (GtkWidget * wid, gpointer unused) { char *buf; /* let python.so or perl.so handle it */ + target_sess = plugingui_get_target_session (); + if (!target_sess) + { + g_free (modname); + g_free (file); + return; + } + if (strchr (file, ' ')) buf = g_strdup_printf ("UNLOAD \"%s\"", file); else buf = g_strdup_printf ("UNLOAD %s", file); - handle_command (current_sess, buf, FALSE); + handle_command (target_sess, buf, FALSE); g_free (buf); } @@ -251,16 +270,24 @@ static void plugingui_reloadbutton_cb (GtkWidget *wid, GtkTreeView *view) { char *file = plugingui_getfilename(view); + session *target_sess; if (file) { char *buf; + target_sess = plugingui_get_target_session (); + if (!target_sess) + { + g_free (file); + return; + } + if (strchr (file, ' ')) buf = g_strdup_printf ("RELOAD \"%s\"", file); else buf = g_strdup_printf ("RELOAD %s", file); - handle_command (current_sess, buf, FALSE); + handle_command (target_sess, buf, FALSE); g_free (buf); g_free (file); } @@ -270,6 +297,7 @@ void plugingui_open (void) { GtkWidget *view; + GtkWidget *view_scroll; GtkWidget *vbox, *hbox; char buf[128]; @@ -285,6 +313,9 @@ plugingui_open (void) gtkutil_destroy_on_esc (plugin_window); view = plugingui_treeview_new (vbox); + view_scroll = gtk_widget_get_parent (view); + if (view_scroll) + gtk_box_set_child_packing (GTK_BOX (vbox), view_scroll, TRUE, TRUE, 0, GTK_PACK_START); g_object_set_data (G_OBJECT (plugin_window), "view", view);