changeset 14801:1986872f2868

[gaim-migrate @ 17566] fix searching in an empty conversation (SF bug #1582852) committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 23 Oct 2006 18:10:51 +0000
parents c678034a7e3e
children 4138063d89c9
files gtk/gtkimhtml.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkimhtml.c	Mon Oct 23 17:53:55 2006 +0000
+++ b/gtk/gtkimhtml.c	Mon Oct 23 18:10:51 2006 +0000
@@ -3531,22 +3531,25 @@
 {
 	GtkTextIter iter, start, end;
 	gboolean new_search = TRUE;
+	GtkTextMark *start_mark;
 
 	g_return_val_if_fail(imhtml != NULL, FALSE);
 	g_return_val_if_fail(text != NULL, FALSE);
 
-	if (imhtml->search_string && !strcmp(text, imhtml->search_string))
+	start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search");
+
+	if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string))
 		new_search = FALSE;
 
 	if (new_search) {
 		gtk_imhtml_search_clear(imhtml);
+		g_free(imhtml->search_string);
+		imhtml->search_string = g_strdup(text);
 		gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter);
 	} else {
 		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter,
-						 gtk_text_buffer_get_mark(imhtml->text_buffer, "search"));
+						 start_mark);
 	}
-	g_free(imhtml->search_string);
-	imhtml->search_string = g_strdup(text);
 
 	if (gtk_source_iter_forward_search(&iter, imhtml->search_string,
 	                                   GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE,