[mutter/gnome-3-32] surface-actor-x11: Assign X11 Display only if we have resources



commit 0a8fbbe5cc5d5bc06e2630b391849e5f9c4db5ad
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Jun 28 09:36:08 2019 +0000

    surface-actor-x11: Assign X11 Display only if we have resources
    
    free_damage and detach_pixmap functions are called inside dispose and an object
    can be disposed multiple times, even when the display is already closed.
    
    So, don't try to deference a possibly null-pointer, assigning the xdisplay too
    early, as if the X11 related resources have been unset, the server might not be
    open anymore. In fact, we assume that if we have a damage or a pixmap set,
    the display is still open.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/660
    
    
    (cherry picked from commit d7d97f247767ace2655f1fd2a7bbee0c0c8cfb50)

 src/compositor/meta-surface-actor-x11.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
index 244b1e885..341bd8b83 100644
--- a/src/compositor/meta-surface-actor-x11.c
+++ b/src/compositor/meta-surface-actor-x11.c
@@ -71,11 +71,13 @@ static void
 free_damage (MetaSurfaceActorX11 *self)
 {
   MetaDisplay *display = self->display;
-  Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
+  Display *xdisplay;
 
   if (self->damage == None)
     return;
 
+  xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
+
   meta_x11_error_trap_push (display->x11_display);
   XDamageDestroy (xdisplay, self->damage);
   self->damage = None;
@@ -86,12 +88,14 @@ static void
 detach_pixmap (MetaSurfaceActorX11 *self)
 {
   MetaDisplay *display = self->display;
-  Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
   MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self));
+  Display *xdisplay;
 
   if (self->pixmap == None)
     return;
 
+  xdisplay = meta_x11_display_get_xdisplay (display->x11_display);
+
   /* Get rid of all references to the pixmap before freeing it; it's unclear whether
    * you are supposed to be able to free a GLXPixmap after freeing the underlying
    * pixmap, but it certainly doesn't work with current DRI/Mesa


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]