Commit 73153b42 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

Use an unused high bit in the XID to mark fonts in the global xid hash

2006-01-19  Matthias Clasen  <mclasen@redhat.com>

	* gdk/x11/gdkprivate-x11.h (XID_FONT_BIT):
	* gdk/x11/gdkfont-x11.c:
	* gdk/x11/gdkxid.c: Use an unused high bit in the
	XID to mark fonts in the global xid hash table.

	* gdk/x11/gdkcursor-x11.c (update_cursor): Skip fonts
	when iterating over the xid hash table, since calling
	GDK_IS_WINDOW () on an GdkFont can cause a segfault.
	(#327751, Ryan Lortie)
parent 292c69ac
......@@ -430,8 +430,12 @@ update_cursor (gpointer key,
gpointer value,
gpointer data)
{
XID *xid = key;
GdkCursor *cursor;
if (*xid & XID_FONT_BIT)
return;
if (!GDK_IS_WINDOW (value))
return;
......
......@@ -50,6 +50,7 @@ struct _GdkFontPrivateX
GdkDisplay *display;
GSList *names;
XID xid;
};
static GHashTable *
......@@ -214,13 +215,14 @@ gdk_font_load_for_display (GdkDisplay *display,
private->xfont = xfont;
private->base.ref_count = 1;
private->names = NULL;
private->xid = xfont->fid | XID_FONT_BIT;
font = (GdkFont*) private;
font->type = GDK_FONT_FONT;
font->ascent = xfont->ascent;
font->descent = xfont->descent;
_gdk_xid_table_insert (display, &xfont->fid, font);
_gdk_xid_table_insert (display, &private->xid, font);
}
gdk_font_hash_insert (GDK_FONT_FONT, font, font_name);
......
......@@ -86,6 +86,8 @@ struct _GdkVisualPrivate
GdkScreen *screen;
};
#define XID_FONT_BIT (1<<31)
void _gdk_xid_table_insert (GdkDisplay *display,
XID *xid,
gpointer data);
......
......@@ -36,6 +36,11 @@ static gboolean gdk_xid_equal (XID *a,
XID *b);
/* The 3 high bits of XIDs are unused. We use one to mark fonts,
* since we must be able to skip fonts when iterating over all XIDs.
*/
#define XID_FONT_BIT (1<<31)
void
_gdk_xid_table_insert (GdkDisplay *display,
XID *xid,
......@@ -123,7 +128,7 @@ static gboolean
gdk_xid_equal (XID *a,
XID *b)
{
return (*a == *b);
return ((*a & ~XID_FONT_BIT) == (*b & ~XID_FONT_BIT));
}
#define __GDK_XID_C__
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment