[mutter/wip/carlosg/x11less-preparations: 1/15] x11: Make error trap API NULL safe
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/x11less-preparations: 1/15] x11: Make error trap API NULL safe
- Date: Wed, 30 Jan 2019 15:57:32 +0000 (UTC)
commit ae65939053b3a4a430ec7b9db05ad4aea19f822c
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Dec 30 12:19:24 2018 +0100
x11: Make error trap API NULL safe
There's quite a few places where error traps are used on high level
code (i.e. not calling X11 itself) in order to coalesce the error
handling for all X11 operations deeper in the callstack.
This does not play well if display->x11_display is nullable. In
order to avoid adding notions about it in code that's otherwise not
related to MetaX11Display, make the error trap API accept NULL by
itself, so it's safe to call with no X11 display.
ATM we just lie and say "Success" if we are popping an error value
if the is no X11 display present. This makes sense if the X11 display
was nonexistent before pushing the trap, as no X11 calls should
happen then. The returned error should be different if the X11 display
became NULL while inside the error trap, but the X11 connection will
die anyway, so this is currently moot.
src/x11/meta-x11-errors.c | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/src/x11/meta-x11-errors.c b/src/x11/meta-x11-errors.c
index 506769464..3dc542da2 100644
--- a/src/x11/meta-x11-errors.c
+++ b/src/x11/meta-x11-errors.c
@@ -49,17 +49,23 @@
void
meta_x11_error_trap_push (MetaX11Display *x11_display)
{
+ if (!x11_display)
+ return;
gdk_x11_display_error_trap_push (x11_display->gdk_display);
}
void
meta_x11_error_trap_pop (MetaX11Display *x11_display)
{
+ if (!x11_display)
+ return;
gdk_x11_display_error_trap_pop_ignored (x11_display->gdk_display);
}
int
meta_x11_error_trap_pop_with_return (MetaX11Display *x11_display)
{
+ if (!x11_display)
+ return BadImplementation;
return gdk_x11_display_error_trap_pop (x11_display->gdk_display);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]