[evolution-patches] Patch fixing crasher bug and surrounding text support



Surrounding text support for input methods in gtkhtml 3.11.x is broken.
First, it crashes when actually called [1]. Second, even the crash is
fixed, there remain some logical flaws [2].

The attached patch fixes both bugs. (See the corresponding
comments in bugzilla for the reasons.)

[1] http://bugzilla.gnome.org/show_bug.cgi?id=353192
[2] http://bugzilla.gnome.org/show_bug.cgi?id=270248#c7

--
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/
? po/th.po.autosave
? src/.htmlengine.h.swp
Index: src/gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.623
diff -u -r1.623 gtkhtml.c
--- src/gtkhtml.c	17 Aug 2006 06:43:54 -0000	1.623
+++ src/gtkhtml.c	28 Aug 2006 10:56:08 -0000
@@ -3357,8 +3357,15 @@
 	}
 
 	while (o) {
-		if (html_object_is_text (o))
-			text = g_strconcat (text, HTML_TEXT (o)->text, NULL);
+		if (html_object_is_text (o)) {
+			if (!text)
+				text = g_strdup (HTML_TEXT (o)->text);
+			else {
+				gchar *concat = g_strconcat (text, HTML_TEXT (o)->text, NULL);
+				g_free (text);
+				text = concat;
+			}
+		}
 		o = html_object_next_not_slave (o);
 	}
 
@@ -3374,7 +3381,13 @@
 	D_IM (printf ("IM gtk_html_im_retrieve_surrounding_cb\n");)
 
 	text = get_surrounding_text (html->engine, &offset);
-	gtk_im_context_set_surrounding (context, text, -1, offset);
+	if (text) {
+		/* convert char offset to byte offset */
+		offset = g_utf8_offset_to_pointer (text, offset) - text;
+		gtk_im_context_set_surrounding (context, text, -1, offset);
+		g_free (text);
+	} else
+		gtk_im_context_set_surrounding (context, NULL, 0, 0);
 
 	return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]