make sure we always return a copy of the window manager name, not a static

2007-05-23  Jens Granseuer  <jensgr@gmx.net>

	* wm-common.c: (wm_common_get_current_window_manager): make sure we
	always return a copy of the window manager name, not a static string
	(fixes bug #439244)

svn path=/trunk/; revision=7650
This commit is contained in:
Jens Granseuer 2007-05-23 17:30:07 +00:00 committed by Jens Granseuer
parent 878855e507
commit c1a2b46553
2 changed files with 19 additions and 20 deletions

View file

@ -1,3 +1,9 @@
2007-05-23 Jens Granseuer <jensgr@gmx.net>
* wm-common.c: (wm_common_get_current_window_manager): make sure we
always return a copy of the window manager name, not a static string
(fixes bug #439244)
2007-05-19 Jens Granseuer <jensgr@gmx.net> 2007-05-19 Jens Granseuer <jensgr@gmx.net>
* gconf-property-editor.c: (peditor_tree_view_widget_changed): * gconf-property-editor.c: (peditor_tree_view_widget_changed):

View file

@ -27,41 +27,34 @@ wm_common_get_current_window_manager (void)
guchar *val; guchar *val;
if (wm_window == None) if (wm_window == None)
return WM_COMMON_UNKNOWN; return g_strdup (WM_COMMON_UNKNOWN);
utf8_string = XInternAtom (GDK_DISPLAY (), "UTF8_STRING", False); utf8_string = XInternAtom (GDK_DISPLAY (), "UTF8_STRING", False);
atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False); atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False);
gdk_error_trap_push (); gdk_error_trap_push ();
val = NULL;
result = XGetWindowProperty (GDK_DISPLAY (), result = XGetWindowProperty (GDK_DISPLAY (),
wm_window, wm_window,
atom, atom,
0, G_MAXLONG, 0, G_MAXLONG,
False, utf8_string, False, utf8_string,
&type, &format, &nitems, &type, &format, &nitems,
&bytes_after, (guchar **)&val); &bytes_after, &val);
if (gdk_error_trap_pop () || result != Success) if (gdk_error_trap_pop () || result != Success ||
return WM_COMMON_UNKNOWN; type != utf8_string || format != 8 || nitems == 0 ||
!g_utf8_validate (val, nitems, NULL))
if (type != utf8_string ||
format !=8 ||
nitems == 0)
{ {
if (val) retval = g_strdup (WM_COMMON_UNKNOWN);
XFree (val);
return WM_COMMON_UNKNOWN;
} }
else
if (!g_utf8_validate (val, nitems, NULL))
{ {
XFree (val);
return WM_COMMON_UNKNOWN;
}
retval = g_strndup (val, nitems); retval = g_strndup (val, nitems);
}
if (val)
XFree (val); XFree (val);
return retval; return retval;