x11: Be a lot more careful about setting ParentRelative

We don't want to set ParentRelative when:

- the parent window is NULL
  In that case we are unsure about the depth, so better err on the side
  of caution and avoid a BadMatch by accepting ugly output.
- the cairo pattern is in an error status
  This should never happen - unless you start up in OOM - but better
  be safe than sorry.

Might help with the spurious crashes in #1280.
This commit is contained in:
Benjamin Otte
2018-12-13 05:22:18 +01:00
parent 2905fc861a
commit 6a47e9a8b9

View File

@ -3005,7 +3005,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
/* X throws BadMatch if the parent has a different depth when
* using ParentRelative */
parent = gdk_window_get_parent (window);
if (parent == NULL || window->depth == parent->depth)
if (parent != NULL && window->depth == parent->depth &&
cairo_pattern_status (pattern) == CAIRO_STATUS_SUCCESS)
{
XSetWindowBackgroundPixmap (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), ParentRelative);