Commit 8d5b4e9f authored by Havoc Pennington's avatar Havoc Pennington Committed by Matthias Clasen

Replace crufty old code for gdk error traps with GQueue and GSlice

No need to do a manual free list these days.

https://bugzilla.gnome.org/show_bug.cgi?id=629608
parent de3512db
......@@ -85,8 +85,7 @@ static int gdk_x_io_error (Display *display);
/* Private variable declarations
*/
static GSList *gdk_error_traps = NULL; /* List of error traps */
static GSList *gdk_error_trap_free_list = NULL; /* Free list */
static GQueue gdk_error_traps;
const GOptionEntry _gdk_windowing_args[] = {
{ "sync", 0, 0, G_OPTION_ARG_NONE, &_gdk_synchronize,
......@@ -98,7 +97,8 @@ void
_gdk_windowing_init (void)
{
_gdk_x11_initialize_locale ();
g_queue_init (&gdk_error_traps);
XSetErrorHandler (gdk_x_error);
XSetIOErrorHandler (gdk_x_io_error);
......@@ -401,28 +401,15 @@ gdk_x_io_error (Display *display)
void
gdk_error_trap_push (void)
{
GSList *node;
GdkErrorTrap *trap;
if (gdk_error_trap_free_list)
{
node = gdk_error_trap_free_list;
gdk_error_trap_free_list = gdk_error_trap_free_list->next;
}
else
{
node = g_slist_alloc ();
node->data = g_new (GdkErrorTrap, 1);
}
node->next = gdk_error_traps;
gdk_error_traps = node;
trap = g_slice_new (GdkErrorTrap);
trap = node->data;
trap->old_handler = XSetErrorHandler (gdk_x_error);
trap->error_code = _gdk_error_code;
trap->error_warnings = _gdk_error_warnings;
g_queue_push_head (&gdk_error_traps, trap);
_gdk_error_code = 0;
_gdk_error_warnings = 0;
}
......@@ -430,25 +417,21 @@ gdk_error_trap_push (void)
gint
gdk_error_trap_pop (void)
{
GSList *node;
GdkErrorTrap *trap;
gint result;
g_return_val_if_fail (gdk_error_traps != NULL, 0);
trap = g_queue_pop_head (&gdk_error_traps);
node = gdk_error_traps;
gdk_error_traps = gdk_error_traps->next;
node->next = gdk_error_trap_free_list;
gdk_error_trap_free_list = node;
g_return_val_if_fail (trap != NULL, 0);
result = _gdk_error_code;
trap = node->data;
_gdk_error_code = trap->error_code;
_gdk_error_warnings = trap->error_warnings;
XSetErrorHandler (trap->old_handler);
g_slice_free (GdkErrorTrap, trap);
return result;
}
......
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