Commit f581dcca authored by Xan Lopez's avatar Xan Lopez Committed by Xan Lopez

reset the completion prefix on Enter too, plug potential leak. Follow-up

2007-07-31  Xan Lopez  <xan@gnome.org>

	* gtk/gtkentry.c (gtk_entry_completion_key_press): reset the
	completion prefix on Enter too, plug potential leak.
	Follow-up to #458298

svn path=/trunk/; revision=18559
parent b1126259
2007-07-31 Xan Lopez <xan@gnome.org>
* gtk/gtkentry.c (gtk_entry_completion_key_press): reset the
completion prefix on Enter too, plug potential leak.
Follow-up to #458298
2007-07-31 Matthias Clasen <mclasen@redhat.com> 2007-07-31 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktooltip.c (gtk_tooltip_init): Make the label * gtk/gtktooltip.c (gtk_tooltip_init): Make the label
......
...@@ -5896,15 +5896,18 @@ gtk_entry_completion_key_press (GtkWidget *widget, ...@@ -5896,15 +5896,18 @@ gtk_entry_completion_key_press (GtkWidget *widget,
GtkTreeSelection *sel; GtkTreeSelection *sel;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreeModel *model = NULL; GtkTreeModel *model = NULL;
gboolean retval = TRUE;
_gtk_entry_reset_im_context (GTK_ENTRY (widget)); _gtk_entry_reset_im_context (GTK_ENTRY (widget));
_gtk_entry_completion_popdown (completion); _gtk_entry_completion_popdown (completion);
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view)); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
if (!gtk_tree_selection_get_selected (sel, &model, &iter)) if (!gtk_tree_selection_get_selected (sel, &model, &iter))
return FALSE; {
retval = FALSE;
if (completion->priv->inline_selection) goto keypress_completion_out;
}
else if (completion->priv->inline_selection)
{ {
/* Escape rejects the tentative completion */ /* Escape rejects the tentative completion */
if (event->keyval == GDK_Escape) if (event->keyval == GDK_Escape)
...@@ -5924,12 +5927,16 @@ gtk_entry_completion_key_press (GtkWidget *widget, ...@@ -5924,12 +5927,16 @@ gtk_entry_completion_key_press (GtkWidget *widget,
gtk_editable_set_position (GTK_EDITABLE (widget), -1); gtk_editable_set_position (GTK_EDITABLE (widget), -1);
else else
gtk_editable_set_position (GTK_EDITABLE (widget), 0); gtk_editable_set_position (GTK_EDITABLE (widget), 0);
}
keypress_completion_out:
if (completion->priv->inline_selection)
{
g_free (completion->priv->completion_prefix); g_free (completion->priv->completion_prefix);
completion->priv->completion_prefix = NULL; completion->priv->completion_prefix = NULL;
} }
return TRUE; return retval;
} }
else if (event->keyval == GDK_Tab || else if (event->keyval == GDK_Tab ||
event->keyval == GDK_KP_Tab || event->keyval == GDK_KP_Tab ||
...@@ -5937,15 +5944,12 @@ gtk_entry_completion_key_press (GtkWidget *widget, ...@@ -5937,15 +5944,12 @@ gtk_entry_completion_key_press (GtkWidget *widget,
{ {
GtkDirectionType dir = event->keyval == GDK_ISO_Left_Tab ? GtkDirectionType dir = event->keyval == GDK_ISO_Left_Tab ?
GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD; GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
_gtk_entry_reset_im_context (GTK_ENTRY (widget)); _gtk_entry_reset_im_context (GTK_ENTRY (widget));
_gtk_entry_completion_popdown (completion); _gtk_entry_completion_popdown (completion);
if (completion->priv->completion_prefix) g_free (completion->priv->completion_prefix);
{ completion->priv->completion_prefix = NULL;
g_free (completion->priv->completion_prefix);
completion->priv->completion_prefix = NULL;
}
gtk_widget_child_focus (gtk_widget_get_toplevel (widget), dir); gtk_widget_child_focus (gtk_widget_get_toplevel (widget), dir);
...@@ -5969,10 +5973,10 @@ gtk_entry_completion_key_press (GtkWidget *widget, ...@@ -5969,10 +5973,10 @@ gtk_entry_completion_key_press (GtkWidget *widget,
if (!gtk_tree_selection_get_selected (sel, &model, &iter)) if (!gtk_tree_selection_get_selected (sel, &model, &iter))
return FALSE; return FALSE;
g_signal_handler_block (widget, completion->priv->changed_id); g_signal_handler_block (widget, completion->priv->changed_id);
g_signal_emit_by_name (completion, "match_selected", g_signal_emit_by_name (completion, "match_selected",
model, &iter, &entry_set); model, &iter, &entry_set);
g_signal_handler_unblock (widget, completion->priv->changed_id); g_signal_handler_unblock (widget, completion->priv->changed_id);
if (!entry_set) if (!entry_set)
{ {
...@@ -5990,6 +5994,9 @@ gtk_entry_completion_key_press (GtkWidget *widget, ...@@ -5990,6 +5994,9 @@ gtk_entry_completion_key_press (GtkWidget *widget,
g_free (str); g_free (str);
} }
g_free (completion->priv->completion_prefix);
completion->priv->completion_prefix = NULL;
return TRUE; return TRUE;
} }
else if (completion->priv->current_selected - matches >= 0) else if (completion->priv->current_selected - matches >= 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment