diff src/xfns.c @ 83632:cc587bfd19ca

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 781-792) - Update from CVS - Merge from gnus--rel--5.10 - Merge from emacs--rel--22 * emacs--rel--22 (patch 33-41) * gnus--rel--5.10 (patch 226-228) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-21
author Miles Bader <miles@gnu.org>
date Mon, 11 Jun 2007 01:00:07 +0000
parents dc002877ce12 7edf1ae10375
children 9c01792a3ce8
line wrap: on
line diff
--- a/src/xfns.c	Mon Jun 04 05:58:18 2007 +0000
+++ b/src/xfns.c	Mon Jun 11 01:00:07 2007 +0000
@@ -1525,6 +1525,8 @@
 /* Encode Lisp string STRING as a text in a format appropriate for
    XICCC (X Inter Client Communication Conventions).
 
+   This can call Lisp code, so callers must GCPRO.
+
    If STRING contains only ASCII characters, do no conversion and
    return the string data of STRING.  Otherwise, encode the text by
    CODING_SYSTEM, and return a newly allocated memory area which
@@ -1572,7 +1574,11 @@
       && SYMBOLP (coding.pre_write_conversion)
       && !NILP (Ffboundp (coding.pre_write_conversion)))
     {
+      struct gcpro gcpro1;
+      /* We don't need to GCPRO string.  */
+      GCPRO1 (coding_system);
       string = run_pre_post_conversion_on_str (string, &coding, 1);
+      UNGCPRO;
       str = SDATA (string);
       chars = SCHARS (string);
       bytes = SBYTES (string);
@@ -1614,6 +1620,16 @@
 	int bytes, stringp;
         int do_free_icon_value = 0, do_free_text_value = 0;
 	Lisp_Object coding_system;
+#ifdef USE_GTK
+	Lisp_Object encoded_name;
+	struct gcpro gcpro1;
+
+	/* As ENCODE_UTF_8 may cause GC and relocation of string data,
+	   we use it before x_encode_text that may return string data.  */
+	GCPRO1 (name);
+	encoded_name = ENCODE_UTF_8 (name);
+	UNGCPRO;
+#endif
 
 	coding_system = Qcompound_text;
 	/* Note: Encoding strategy
@@ -1654,7 +1670,7 @@
 
 #ifdef USE_GTK
         gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                              (char *) SDATA (ENCODE_UTF_8 (name)));
+                              (char *) SDATA (encoded_name));
 #else /* not USE_GTK */
 	XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
 #endif /* not USE_GTK */
@@ -1840,9 +1856,9 @@
 				    build_string (foreground_p
 						  ? "foreground"
 						  : "background"),
-				    empty_string,
+				    empty_unibyte_string,
 				    build_string ("verticalScrollBar"),
-				    empty_string);
+				    empty_unibyte_string);
       if (!STRINGP (tem))
 	{
 	  /* If nothing has been specified, scroll bars will use a