Revamp and modernize X error traps

* add per-display gdk_x11_display_error_trap_push()
  (X11-specific because gdk_error_trap_push() probably
  should have been)
* make gdk_error_trap_push() handle only GDK displays
  not displays opened without a GDK wrapper
* make gdk_error_trap_pop() and gdk_x11_display_error_trap_pop()
  automatically sync only if needed, so manual gdk_flush() is not
  required
* add gdk_error_trap_pop_ignored() which just asynchronously
  ignores errors, so never needs to sync
* add G_GNUC_WARN_UNUSED_RESULT to plain pop(), because
  if you use plain pop() and don't need the return value,
  the async gdk_error_trap_pop_ignored() should be used
  instead. This results in lots of warnings to clean
  up in a later patch.

The main objective here was to avoid the need to sync just
to ignore an error. Now, syncing is automatic, and only
happens when we need to know the error code.

https://bugzilla.gnome.org/show_bug.cgi?id=629608
This commit is contained in:
Havoc Pennington
2010-09-18 18:19:27 -04:00
committed by Matthias Clasen
parent 4f3e5e6ebc
commit b837ef5a6d
11 changed files with 488 additions and 132 deletions

View File

@ -326,42 +326,6 @@ available.
@void:
<!-- ##### FUNCTION gdk_error_trap_push ##### -->
<para>
This function allows X errors to be trapped instead of the normal behavior
of exiting the application. It should only be used if it is not possible to
avoid the X error in any other way.
</para>
<example>
<title>Trapping an X error</title>
<programlisting>
gdk_error_trap_push (<!-- -->);
/* ... Call the X function which may cause an error here ... */
/* Flush the X queue to catch errors now. */
gdk_flush (<!-- -->);
if (gdk_error_trap_pop (<!-- -->))
{
/* ... Handle the error here ... */
}
</programlisting>
</example>
@void:
<!-- ##### FUNCTION gdk_error_trap_pop ##### -->
<para>
Removes the X error trap installed with gdk_error_trap_push().
</para>
@void:
@Returns: the X error code, or 0 if no error occurred.
<!-- ##### MACRO GDK_WINDOWING_X11 ##### -->
<para>
This macro is defined if GDK is configured to use the X11 backend.