Re: sawfish 1.3.2 segfault



Gabor Z. Papp said:     (by the date of Mon, 21 Jan 2008 22:16:54 +0100)

> Hello Janek and Rodrigo,
> 
> found a segfault with 1.3.2 and current svn as today.
> 
> Trying to open a file probably with utf8 name:
> 
> $ ls -l tmp/k*
> -rw------- 1 gzp gzp 608252 Jan 20 18:09 tmp/k??p 003.jpg
> -rw------- 1 gzp gzp 698250 Jan 20 18:09 tmp/k??p 004.jpg
> 
> Probably related to patch by Rodrigo.
> 
> 1.3.1 was ok.


Hello,

would be nice if you will send further replies to this mailing list.

What an "open a file" operation does? I tried from xterm:

  gqview wierd_utf8_name.png

and it worked - more precisely: what is your "crashing" command?

What does 'locale' command print in your xterm, before you lanuch this
"crashing" command?


Can you make sure if un-applying Rodrigo's patch removes your
problem? Try the attached patch.

  patch -p0 < removeNMWProps.diff

you could also try un-applying other patches, by getting various diffs
from SVN, I obtained this one with command:

svn diff http://svn.gnome.org/svn/sawfish/trunk 4211 http://svn.gnome.org/svn/sawfish/trunk 4210 > removeNMWProps.diff


best regards
-- 
# Janek Kozicki
Index: src/display.c
===================================================================
--- src/display.c	(revision 4211)
+++ src/display.c	(revision 4210)
@@ -55,8 +55,7 @@
 
 /* some atoms that may be useful.. */
 Atom xa_wm_state, xa_wm_change_state, xa_wm_protocols, xa_wm_delete_window,
-  xa_wm_colormap_windows, xa_wm_take_focus, xa_compound_text,
-  xa_wm_net_name, xa_wm_net_icon_name, xa_utf8_string;
+    xa_wm_colormap_windows, xa_wm_take_focus, xa_compound_text;
 
 DEFSYM(display_name, "display-name");
 DEFSYM(canonical_display_name, "canonical-display-name");
@@ -336,9 +335,6 @@
 	    xa_wm_colormap_windows = XInternAtom (dpy, "WM_COLORMAP_WINDOWS", False);
 	    xa_wm_take_focus = XInternAtom (dpy, "WM_TAKE_FOCUS", False);
 	    xa_compound_text = XInternAtom (dpy, "COMPOUND_TEXT", False);
-	    xa_wm_net_name = XInternAtom (dpy, "_NET_WM_NAME", False);
-	    xa_wm_net_icon_name = XInternAtom (dpy, "_NET_WM_ICON_NAME", False);
-	    xa_utf8_string = XInternAtom (dpy, "UTF8_STRING", False);
 
 	    if (!XShapeQueryExtension (dpy, &shape_event_base,
 				       &shape_error_base))
Index: src/sawmill.h
===================================================================
--- src/sawmill.h	(revision 4211)
+++ src/sawmill.h	(revision 4210)
@@ -147,7 +147,6 @@
     Window *cmap_windows;
     int n_cmap_windows;
     repv full_name, name, icon_name;
-    repv net_name, net_icon_name;
     int frame_vis;
     repv icon_image;
 
Index: src/fonts.c
===================================================================
--- src/fonts.c	(revision 4211)
+++ src/fonts.c	(revision 4210)
@@ -311,11 +311,7 @@
 static int
 fontset_measure (Lisp_Font *f, u_char *string, size_t length)
 {
-#ifdef X_HAVE_UTF8_STRING
-    return Xutf8TextEscapement (f->font, string, length);
-#else
     return XmbTextEscapement (f->font, string, length);
-#endif
 }
 
 static void
@@ -326,11 +322,8 @@
 
     gcv.foreground = fg->pixel;
     XChangeGC (dpy, gc, GCForeground, &gcv);
-#ifdef X_HAVE_UTF8_STRING
-    Xutf8DrawString (dpy, id, f->font, gc, x, y, string, length);
-#else
+
     XmbDrawString (dpy, id, f->font, gc, x, y, string, length);
-#endif
 }
 
 static const Lisp_Font_Class fontset_class = {
@@ -372,7 +365,7 @@
 {
     XGlyphInfo info;
 
-    XftTextExtentsUtf8 (dpy, f->font, string, length, &info);
+    XftTextExtents8 (dpy, f->font, string, length, &info);
 
     return info.xOff; 
 }
@@ -396,7 +389,7 @@
     xft_color.color.blue = fg->blue;
     xft_color.color.alpha = fg->alpha;
 
-    XftDrawStringUtf8 (draw, &xft_color, f->font,
+    XftDrawString8 (draw, &xft_color, f->font,
 		    x, y, string, length);
 }
 
@@ -482,14 +475,24 @@
 static int
 pango_measure (Lisp_Font *f, u_char *string, size_t length)
 {
+    gsize r, w;
+    u_char *utf8str;
     PangoLayout *layout;
     PangoRectangle rect;
 
+    utf8str = g_locale_to_utf8 (string, length, &r, &w, NULL);
+    if (utf8str != NULL)
+    {
+	string = utf8str;
+	length = w;
+    }
+
     layout = pango_layout_new (pango_context);
     pango_layout_set_text (layout, string, length);
 
     pango_layout_get_extents (layout, NULL, &rect);
 
+    g_free (utf8str);
     g_object_unref (layout);
  
     return rect.width / PANGO_SCALE;
@@ -526,6 +529,8 @@
 {
     static XftDraw *draw;
     XftColor xft_color;
+    gsize r, w;
+    u_char *utf8str;
     PangoLayout *layout;
     PangoLayoutIter *iter;
 
@@ -540,6 +545,13 @@
     xft_color.color.blue = fg->blue;
     xft_color.color.alpha = fg->alpha;
 
+    utf8str = g_locale_to_utf8 (string, length, &r, &w, NULL);
+    if (utf8str != NULL)
+    {
+	string = utf8str;
+	length = w;
+    }
+
     layout = pango_layout_new (pango_context);
     pango_layout_set_text (layout, string, length);
     iter = pango_layout_get_iter (layout);
@@ -553,6 +565,7 @@
 			 line, x + rect.x / PANGO_SCALE, y);
     } while (pango_layout_iter_next_line (iter));
 
+    g_free (utf8str);
     g_object_unref (layout);
     pango_layout_iter_free (iter);
 }
Index: src/windows.c
===================================================================
--- src/windows.c	(revision 4211)
+++ src/windows.c	(revision 4210)
@@ -356,85 +356,6 @@
     }
 }
 
-/* Queries X properties to get the window {icon,}name */
-static void
-get_window_name(Lisp_Window * w)
-{
-  char *tem;
-  XTextProperty prop;
-
-  /* We only try to use the utf8 properties if our xlib supports them */
-#ifdef X_HAVE_UTF8_STRING
-  if (XGetTextProperty (dpy, w->id, &prop, xa_wm_net_name) && prop.value) {
-    if (prop.nitems > 0)
-      {
-        char **list;
-	int count;
-	prop.nitems = strlen(prop.value);
-	if (Xutf8TextPropertyToTextList (dpy, &prop, &list, &count)
-	    >= Success)
-	  {
-	    if (count > 0)
-	      w->net_name = rep_string_dup (list[0]);
-	    XFreeStringList (list);
-	  }
-      }
-  }
-
-  if (XGetTextProperty (dpy, w->id, &prop, xa_wm_net_icon_name) && prop.value) {
-    if (prop.nitems > 0)
-      {
-        char **list;
-	int count;
-	prop.nitems = strlen(prop.value);
-	if (Xutf8TextPropertyToTextList (dpy, &prop, &list, &count)
-	    >= Success)
-	  {
-	    if (count > 0)
-	      w->net_icon_name = rep_string_dup (list[0]);
-	    XFreeStringList (list);
-	  }
-      }
-  }
-
-  /* If we got the _NET names, there's no point in querying the others, 
-     as they won't be used anyways. */
-  if (w->net_name != Qnil)
-    return;
-
-#endif
-
-  if (XGetWMName (dpy, w->id, &prop) && prop.value)
-    {
-      if (prop.nitems > 0)
-	{
-	  char **list;
-	  int count;
-	  prop.nitems = strlen(prop.value);
-	  if (XmbTextPropertyToTextList (dpy, &prop, &list, &count)
-	      >= Success)
-	    {
-	      if (count > 0)
-		w->name = rep_string_dup (g_locale_to_utf8(list[0],
-							   -1, NULL, NULL, NULL));
-	      XFreeStringList (list);
-	    }
-	}
-      XFree (prop.value);
-    }
-  w->full_name = w->name;
-  
-  if (XGetIconName (dpy, w->id, &tem))
-    {
-      w->icon_name = rep_string_dup (g_locale_to_utf8(tem,
-						      -1, NULL, NULL, NULL));
-      XFree (tem);
-    }
-  else
-    w->icon_name = w->name;
-
-}
-
 /* Add the top-level window ID to the manager's data structures */
 Lisp_Window *
 add_window (Window id)
@@ -448,6 +369,7 @@
 	XWindowChanges xwc;
 	u_int xwcm;
 	long supplied;
+	XTextProperty prop;
 
 	DB(("add_window (%lx)\n", id));
 
@@ -467,8 +389,6 @@
 	w->frame_style = Qnil;;
 	w->icon_image = rep_NULL;
 	w->name = rep_null_string ();
-	w->net_name = Qnil;
-	w->net_icon_name = Qnil;
 
 	/* have to put it somewhere until it finds the right place */
 	insert_in_stacking_list_above_all (w);
@@ -481,7 +401,31 @@
 	DB(("  orig: width=%d height=%d x=%d y=%d\n",
 	    w->attr.width, w->attr.height, w->attr.x, w->attr.y));
 
-	get_window_name(w);
+	if (XGetWMName (dpy, id, &prop) && prop.value)
+	{
+	    if (prop.nitems > 0)
+	    {
+		char **list;
+		int count;
+		prop.nitems = strlen(prop.value);
+		if (XmbTextPropertyToTextList (dpy, &prop, &list, &count)
+		    >= Success)
+		{
+		    if (count > 0)
+			w->name = rep_string_dup (list[0]);
+		    XFreeStringList (list);
+		}
+	    }
+	    XFree (prop.value);
+	}
+	w->full_name = w->name;
+	if (XGetIconName (dpy, id, &tem))
+	{
+	    w->icon_name = rep_string_dup (tem);
+	    XFree (tem);
+	}
+	else
+	    w->icon_name = w->name;
 
 	w->wmhints = XGetWMHints (dpy, id);
 	if (!XGetWMNormalHints (dpy, w->id, &w->hints, &supplied))
@@ -756,10 +700,8 @@
 Return the name of window object WINDOW.
 ::end:: */
 {
-    Lisp_Window * w;
     rep_DECLARE1(win, WINDOWP);
-    w = VWIN(win);
-    return w->net_name != Qnil ? w->net_name : w->name;
+    return VWIN(win)->name;
 }
 
 DEFUN("window-full-name", Fwindow_full_name, Swindow_full_name,
@@ -782,10 +724,8 @@
 Return the name of window object WINDOW's icon.
 ::end:: */
 {
-    Lisp_Window * w;
     rep_DECLARE1(win, WINDOWP);
-    w = VWIN(win);
-    return w->net_icon_name != Qnil ? w->net_icon_name : w->icon_name;
+    return VWIN(win)->icon_name;
 }
 
 DEFUN("window-mapped-p", Fwindow_mapped_p, Swindow_mapped_p,
@@ -1480,8 +1420,6 @@
     rep_MARKVAL(VWIN(win)->name);
     rep_MARKVAL(VWIN(win)->full_name);
     rep_MARKVAL(VWIN(win)->icon_name);
-    rep_MARKVAL(VWIN(win)->net_name);
-    rep_MARKVAL(VWIN(win)->net_icon_name);
     rep_MARKVAL(VWIN(win)->icon_image);
 }
 
Index: src/sawmill_subrs.h
===================================================================
--- src/sawmill_subrs.h	(revision 4211)
+++ src/sawmill_subrs.h	(revision 4210)
@@ -57,7 +57,7 @@
 extern Window root_window, no_focus_window;
 extern Atom xa_wm_state, xa_wm_change_state, xa_wm_protocols,
     xa_wm_delete_window, xa_wm_colormap_windows, xa_wm_take_focus,
-  xa_compound_text, xa_wm_net_name, xa_wm_net_icon_name, xa_utf8_string;
+    xa_compound_text;
 extern int shape_event_base, shape_error_base;
 extern repv Qdisplay_name, Qcanonical_display_name;
 extern bool sys_init (char *program_name);
Index: src/events.c
===================================================================
--- src/events.c	(revision 4211)
+++ src/events.c	(revision 4210)
@@ -476,111 +476,6 @@
        a motion event is actually evaluated) */
 }
 
-
-static bool
-update_window_name(Lisp_Window * w, XPropertyEvent xproperty) {
-  u_char *prop;
-  Atom actual;
-  int format;
-  long nitems, bytes_after;
-  char **text_list;
-  XTextProperty tprop;
-  int count;
-  repv str = Qnil;
-  int convert_status;
-
-  if (xproperty.state != PropertyNewValue
-      || XGetWindowProperty (dpy, w->id, xproperty.atom,
-			     0, 200, False, AnyPropertyType, &actual,
-			     &format, &nitems,
-			     &bytes_after, &prop) != Success
-      || actual == None)
-    return FALSE;
-
-  if (format != 8 || WINDOW_IS_GONE_P (w))
-    return FALSE;
-
-  tprop.value = prop;
-  tprop.encoding = actual;
-  tprop.format = format;
-  tprop.nitems = strlen (prop);
-
-  if (actual == xa_compound_text || actual == XA_STRING) 
-    {
-      convert_status = XmbTextPropertyToTextList (dpy, &tprop, &text_list, &count);
-      if (convert_status >= Success && count > 0) 
-	{
-	  char * utf8str = g_locale_to_utf8(text_list[0], -1, NULL, NULL, NULL);
-	  if (utf8str)
-	    str = rep_string_dup (utf8str);
-	}
-      XFreeStringList(text_list);
-    }
-
-#ifdef X_HAVE_UTF8_STRING
-  if (actual == xa_utf8_string) 
-    {
-      convert_status = Xutf8TextPropertyToTextList (dpy, &tprop, &text_list, &count);
-      if (convert_status >= Success && count > 0)
-	str = rep_string_dup (text_list[0]);
-      XFreeStringList(text_list);
-    }
-#endif
-
-  XFree (prop);
-  
-  if (str == Qnil)
-    return FALSE;
-
-  if (xproperty.atom == xa_wm_net_name)
-    {
-      if ( str != Qnil && Fequal (w->net_name, str) == Qnil)
-	{
-	  w->net_name = str;
-	  return TRUE;
-	}
-    }
-  
-  if (xproperty.atom == xa_wm_net_icon_name) 
-    {
-      if ( str != Qnil && Fequal (w->net_icon_name, str) == Qnil)
-	{
-	  w->net_icon_name = str;
-	  return TRUE;
-	}
-    }
-  
-  /* No point in updating the rest if we have the _NET ones. They won't
-     be used anyways. */
-  if (w->net_name != Qnil)
-    return FALSE;
-  
-  if (xproperty.atom == XA_WM_NAME)
-    {
-      if (str == Qnil)
-	str = rep_null_string ();
-      if (Fequal (w->name, str) == Qnil
-	  || Fequal (w->full_name, str) == Qnil)
-	{
-	  w->full_name = w->name = str;
-	  return TRUE;
-	}
-    }
-  
-  if (xproperty.atom == XA_WM_ICON_NAME)
-    {
-      if (str == Qnil)
-	str = rep_null_string ();
-      if (Fequal (w->icon_name, str) == Qnil)
-	{
-	  w->icon_name = str;
-	  return TRUE;
-	}
-    }	  
-
-  return FALSE;
-}
-
 static void
 property_notify (XEvent *ev)
 {
@@ -594,9 +489,72 @@
 
 	switch (ev->xproperty.atom)
 	{
+	    u_char *prop;
+	    Atom actual;
+	    int format;
+	    long nitems, bytes_after;
 	    long supplied;
 	    bool old_urgency, new_urgency;
 
+	case XA_WM_NAME:
+	case XA_WM_ICON_NAME:
+	    if (ev->xproperty.state == PropertyNewValue
+		&& XGetWindowProperty (dpy, w->id, ev->xproperty.atom,
+				       0, 200, False, AnyPropertyType, &actual,
+				       &format, &nitems,
+				       &bytes_after, &prop) == Success
+		&& actual != None)
+	    {
+		if (format == 8 && !WINDOW_IS_GONE_P (w))
+		{
+		    repv str = Qnil;
+		    if (actual == xa_compound_text || actual == XA_STRING)
+		    {
+			char **text_list;
+			XTextProperty tprop;
+			int count;
+			tprop.value = prop;
+			tprop.encoding = actual;
+			tprop.format = format;
+			tprop.nitems = strlen (prop);
+			if (XmbTextPropertyToTextList (dpy, &tprop,
+						       &text_list, &count)
+			    >= Success)
+			{
+			    if (count > 0)
+			    	str = rep_string_dup (text_list[0]);
+			    XFreeStringList(text_list);
+			}
+		    }
+		    if (str == Qnil)
+			str = rep_null_string ();
+
+		    if (ev->xproperty.atom == XA_WM_NAME)
+		    {
+			if (Fequal (w->name, str) == Qnil
+			    || Fequal (w->full_name, str) == Qnil)
+			{
+			    w->full_name = w->name = str;
+			    need_refresh = TRUE;
+			}
+			else
+			    changed = FALSE;
+		    }
+		    else
+		    {
+			if (Fequal (w->icon_name, str) == Qnil)
+			{
+			    w->icon_name = str;
+			    need_refresh = TRUE;
+			}
+			else
+			    changed = FALSE;
+		    }
+		}
+		XFree (prop);
+	    }
+	    break;
+
 	case XA_WM_HINTS:
 	    old_urgency = w->wmhints != 0 && w->wmhints->flags & XUrgencyHint;
 	    if (w->wmhints != 0)
@@ -614,17 +572,8 @@
 	    break;
 
 	default:
-
-	    if (ev->xproperty.atom == XA_WM_NAME ||
-		ev->xproperty.atom == XA_WM_ICON_NAME ||
-		ev->xproperty.atom == xa_wm_net_name ||
-		ev->xproperty.atom == xa_wm_net_icon_name ) 
+	    if (ev->xproperty.atom == xa_wm_colormap_windows)
 	    {
-	      need_refresh = changed = 
-		update_window_name(w, ev->xproperty);
-	    }
-	    else if (ev->xproperty.atom == xa_wm_colormap_windows)
-	    {
 		if (w->n_cmap_windows > 0)
 		    XFree (w->cmap_windows);
 		if (!XGetWMColormapWindows (dpy, w->id, &w->cmap_windows,


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