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)
This commit is contained in:
Matthias Clasen
2006-01-20 04:39:43 +00:00
committed by Matthias Clasen
parent d8a5439f4d
commit c9473ebd35
6 changed files with 34 additions and 2 deletions

View File

@@ -1,3 +1,15 @@
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)
2006-01-18 Matthias Clasen <mclasen@redhat.com>
* configure.in: Remove "ang" again. Please add

View File

@@ -1,3 +1,15 @@
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)
2006-01-18 Matthias Clasen <mclasen@redhat.com>
* configure.in: Remove "ang" again. Please add

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -123,7 +123,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__