xed-window: Fix a potential crash

This commit is contained in:
JosephMcc 2018-03-11 04:38:24 -07:00
parent 37338603dc
commit 3999de8f59
1 changed files with 10 additions and 4 deletions

View File

@ -497,7 +497,7 @@ received_clipboard_contents (GtkClipboard *clipboard,
GtkSelectionData *selection_data, GtkSelectionData *selection_data,
XedWindow *window) XedWindow *window)
{ {
gboolean sens; gboolean sensitive;
GtkAction *action; GtkAction *action;
/* getting clipboard contents is async, so we need to /* getting clipboard contents is async, so we need to
@ -507,17 +507,23 @@ received_clipboard_contents (GtkClipboard *clipboard,
{ {
XedTabState state; XedTabState state;
gboolean state_normal; gboolean state_normal;
state = xed_tab_get_state (window->priv->active_tab); state = xed_tab_get_state (window->priv->active_tab);
state_normal = (state == XED_TAB_STATE_NORMAL); state_normal = (state == XED_TAB_STATE_NORMAL);
sens = state_normal && gtk_selection_data_targets_include_text (selection_data); sensitive = state_normal && gtk_selection_data_targets_include_text (selection_data);
} }
else else
{ {
sens = FALSE; sensitive = FALSE;
} }
action = gtk_action_group_get_action (window->priv->action_group, "EditPaste"); action = gtk_action_group_get_action (window->priv->action_group, "EditPaste");
gtk_action_set_sensitive (action, sens);
if (action != NULL)
{
gtk_action_set_sensitive (action, sensitive);
}
g_object_unref (window); g_object_unref (window);
} }