From 54e03ab03012f091809ec81e2c52217d0a837a5a Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 9 Jan 2008 07:44:56 +0100 Subject: [PATCH] Make sure selection actions have a widget. The return value of gtk_window_get_focus can be NULL. Return early in that case. --- src/browser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/browser.c b/src/browser.c index ce9f9a44..35d13354 100644 --- a/src/browser.c +++ b/src/browser.c @@ -76,24 +76,32 @@ void on_action_edit_activate(GtkAction* action, CBrowser* browser) void on_action_cut_activate(GtkAction* action, CBrowser* browser) { GtkWidget* widget = gtk_window_get_focus(GTK_WINDOW(browser->window)); + if(G_UNLIKELY(!widget)) + return; g_signal_emit_by_name(widget, "cut-clipboard"); } void on_action_copy_activate(GtkAction* action, CBrowser* browser) { GtkWidget* widget = gtk_window_get_focus(GTK_WINDOW(browser->window)); + if(G_UNLIKELY(!widget)) + return; g_signal_emit_by_name(widget, "copy-clipboard"); } void on_action_paste_activate(GtkAction* action, CBrowser* browser) { GtkWidget* widget = gtk_window_get_focus(GTK_WINDOW(browser->window)); + if(G_UNLIKELY(!widget)) + return; g_signal_emit_by_name(widget, "paste-clipboard"); } void on_action_delete_activate(GtkAction* action, CBrowser* browser) { GtkWidget* widget = gtk_window_get_focus(GTK_WINDOW(browser->window)); + if(G_UNLIKELY(!widget)) + return; if(WEBKIT_IS_WEB_VIEW(widget)) webkit_web_view_delete_selection(WEBKIT_WEB_VIEW(widget)); else if(GTK_IS_EDITABLE(widget)) @@ -103,6 +111,8 @@ void on_action_delete_activate(GtkAction* action, CBrowser* browser) void on_action_selectAll_activate(GtkAction* action, CBrowser* browser) { GtkWidget* widget = gtk_window_get_focus(GTK_WINDOW(browser->window)); + if(G_UNLIKELY(!widget)) + return; if(GTK_IS_ENTRY(widget)) gtk_editable_select_region(GTK_EDITABLE(widget), 0, -1); else