Blame SOURCES/make-cogl-errors-non-fatal.patch

d1d875
From 42781fbacd22546266ce5d29e257cdc2b2661a4a Mon Sep 17 00:00:00 2001
d1d875
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
d1d875
Date: Thu, 14 Apr 2016 16:51:13 +0200
d1d875
Subject: [PATCH 1/2] Do not try to unref NULL CoglObjects
d1d875
d1d875
https://bugzilla.gnome.org/show_bug.cgi?id=765058
d1d875
---
d1d875
 src/backends/meta-cursor.c              | 3 ++-
d1d875
 src/compositor/meta-surface-actor-x11.c | 3 +--
d1d875
 2 files changed, 3 insertions(+), 3 deletions(-)
d1d875
d1d875
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
d1d875
index 22a8a76..ad468c0 100644
d1d875
--- a/src/backends/meta-cursor.c
d1d875
+++ b/src/backends/meta-cursor.c
d1d875
@@ -55,7 +55,8 @@ meta_cursor_reference_ref (MetaCursorReference *self)
d1d875
 static void
d1d875
 meta_cursor_image_free (MetaCursorImage *image)
d1d875
 {
d1d875
-  cogl_object_unref (image->texture);
d1d875
+  if (image->texture)
d1d875
+    cogl_object_unref (image->texture);
d1d875
 
d1d875
 #ifdef HAVE_NATIVE_BACKEND
d1d875
   if (image->bo)
d1d875
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
d1d875
index 4aa7ecd..4a5ac00 100644
d1d875
--- a/src/compositor/meta-surface-actor-x11.c
d1d875
+++ b/src/compositor/meta-surface-actor-x11.c
d1d875
@@ -102,8 +102,7 @@ detach_pixmap (MetaSurfaceActorX11 *self)
d1d875
   priv->pixmap = None;
d1d875
   meta_error_trap_pop (display);
d1d875
 
d1d875
-  cogl_object_unref (priv->texture);
d1d875
-  priv->texture = NULL;
d1d875
+  g_clear_pointer (&priv->texture, cogl_object_unref);
d1d875
 }
d1d875
 
d1d875
 static void
d1d875
-- 
d1d875
2.7.3
d1d875
d1d875
d1d875
From 9522c6ff9bf311c9590ceb6a54cadc75f27ea6e0 Mon Sep 17 00:00:00 2001
d1d875
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
d1d875
Date: Thu, 14 Apr 2016 15:30:31 +0200
d1d875
Subject: [PATCH 2/2] Do not skip CoglError parameters
d1d875
d1d875
While CoglError is a define to GError, it doesn't follow the convention
d1d875
of ignoring errors when NULL is passed, but rather treats the error as
d1d875
fatal :-(
d1d875
That's clearly unwanted for a compositor, so make sure to always pass
d1d875
an error parameter where a runtime error is possible (i.e. any CoglError
d1d875
that is not a malformed blend string).
d1d875
d1d875
https://bugzilla.gnome.org/show_bug.cgi?id=765058
d1d875
---
d1d875
 src/backends/meta-cursor-tracker.c      |  9 ++++++++-
d1d875
 src/backends/meta-cursor.c              | 18 ++++++++++++++++--
d1d875
 src/compositor/meta-background-image.c  |  4 +++-
d1d875
 src/compositor/meta-background.c        | 10 +++++++++-
d1d875
 src/compositor/meta-shadow-factory.c    | 10 +++++++++-
d1d875
 src/compositor/meta-surface-actor-x11.c | 10 ++++++++--
d1d875
 src/compositor/meta-window-actor.c      | 10 +++++++++-
d1d875
 src/wayland/meta-wayland-buffer.c       |  8 +++++++-
d1d875
 8 files changed, 69 insertions(+), 10 deletions(-)
d1d875
d1d875
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
d1d875
index a649cb4..e2ce3af 100644
d1d875
--- a/src/backends/meta-cursor-tracker.c
d1d875
+++ b/src/backends/meta-cursor-tracker.c
d1d875
@@ -213,6 +213,7 @@ ensure_xfixes_cursor (MetaCursorTracker *tracker)
d1d875
   guint8 *cursor_data;
d1d875
   gboolean free_cursor_data;
d1d875
   CoglContext *ctx;
d1d875
+  CoglError *error = NULL;
d1d875
 
d1d875
   if (tracker->xfixes_cursor)
d1d875
     return;
d1d875
@@ -254,11 +255,17 @@ ensure_xfixes_cursor (MetaCursorTracker *tracker)
d1d875
                                           CLUTTER_CAIRO_FORMAT_ARGB32,
d1d875
                                           cursor_image->width * 4, /* stride */
d1d875
                                           cursor_data,
d1d875
-                                          NULL);
d1d875
+                                          &error);
d1d875
 
d1d875
   if (free_cursor_data)
d1d875
     g_free (cursor_data);
d1d875
 
d1d875
+  if (error != NULL)
d1d875
+    {
d1d875
+      meta_warning ("Failed to allocate cursor sprite texture: %s\n", error->message);
d1d875
+      cogl_error_free (error);
d1d875
+    }
d1d875
+
d1d875
   if (sprite != NULL)
d1d875
     {
d1d875
       MetaCursorReference *cursor = meta_cursor_reference_take_texture (sprite,
d1d875
diff --git a/src/backends/meta-cursor.c b/src/backends/meta-cursor.c
d1d875
index ad468c0..e2a7f76 100644
d1d875
--- a/src/backends/meta-cursor.c
d1d875
+++ b/src/backends/meta-cursor.c
d1d875
@@ -222,6 +222,7 @@ meta_cursor_image_load_from_xcursor_image (MetaCursorImage   *image,
d1d875
   CoglPixelFormat cogl_format;
d1d875
   ClutterBackend *clutter_backend;
d1d875
   CoglContext *cogl_context;
d1d875
+  CoglError *error = NULL;
d1d875
 
d1d875
   width           = xc_image->width;
d1d875
   height          = xc_image->height;
d1d875
@@ -243,7 +244,13 @@ meta_cursor_image_load_from_xcursor_image (MetaCursorImage   *image,
d1d875
                                                   cogl_format,
d1d875
                                                   rowstride,
d1d875
                                                   (uint8_t *) xc_image->pixels,
d1d875
-                                                  NULL);
d1d875
+                                                  &error);
d1d875
+
d1d875
+  if (error)
d1d875
+    {
d1d875
+      meta_warning ("Failed to allocate cursor texture: %s\n", error->message);
d1d875
+      cogl_error_free (error);
d1d875
+    }
d1d875
 
d1d875
 #ifdef HAVE_NATIVE_BACKEND
d1d875
   struct gbm_device *gbm = get_gbm_device ();
d1d875
@@ -284,6 +291,7 @@ meta_cursor_image_load_from_buffer (MetaCursorImage    *image,
d1d875
 {
d1d875
   ClutterBackend *backend;
d1d875
   CoglContext *cogl_context;
d1d875
+  CoglError *error = NULL;
d1d875
 
d1d875
   image->hot_x = hot_x;
d1d875
   image->hot_y = hot_y;
d1d875
@@ -291,7 +299,13 @@ meta_cursor_image_load_from_buffer (MetaCursorImage    *image,
d1d875
   backend = clutter_get_default_backend ();
d1d875
   cogl_context = clutter_backend_get_cogl_context (backend);
d1d875
 
d1d875
-  image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, NULL);
d1d875
+  image->texture = cogl_wayland_texture_2d_new_from_buffer (cogl_context, buffer, &error);
d1d875
+
d1d875
+  if (error)
d1d875
+    {
d1d875
+      meta_warning ("Failed to allocate cursor texture:%s\n", error->message);
d1d875
+      cogl_error_free (error);
d1d875
+    }
d1d875
 
d1d875
 #ifdef HAVE_NATIVE_BACKEND
d1d875
   struct gbm_device *gbm = get_gbm_device ();
d1d875
diff --git a/src/compositor/meta-background-image.c b/src/compositor/meta-background-image.c
d1d875
index af66755..0d36246 100644
d1d875
--- a/src/compositor/meta-background-image.c
d1d875
+++ b/src/compositor/meta-background-image.c
d1d875
@@ -144,6 +144,7 @@ file_loaded (GObject      *source_object,
d1d875
 {
d1d875
   MetaBackgroundImage *image = META_BACKGROUND_IMAGE (source_object);
d1d875
   GError *error = NULL;
d1d875
+  CoglError *catch_error = NULL;
d1d875
   GTask *task;
d1d875
   CoglTexture *texture;
d1d875
   GdkPixbuf *pixbuf;
d1d875
@@ -176,9 +177,10 @@ file_loaded (GObject      *source_object,
d1d875
                               has_alpha ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
d1d875
                               row_stride,
d1d875
                               pixels, 0,
d1d875
-                              NULL))
d1d875
+                              &catch_error))
d1d875
     {
d1d875
       g_warning ("Failed to create texture for background");
d1d875
+      cogl_error_free (catch_error);
d1d875
       cogl_object_unref (texture);
d1d875
     }
d1d875
 
d1d875
diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c
d1d875
index 75fbc28..de0407b 100644
d1d875
--- a/src/compositor/meta-background.c
d1d875
+++ b/src/compositor/meta-background.c
d1d875
@@ -17,6 +17,7 @@
d1d875
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
d1d875
  */
d1d875
 
d1d875
+#include <meta/util.h>
d1d875
 #include <meta/meta-background.h>
d1d875
 #include <meta/meta-background-image.h>
d1d875
 #include "meta-background-private.h"
d1d875
@@ -515,6 +516,7 @@ ensure_color_texture (MetaBackground *self)
d1d875
     {
d1d875
       ClutterBackend *backend = clutter_get_default_backend ();
d1d875
       CoglContext *ctx = clutter_backend_get_cogl_context (backend);
d1d875
+      CoglError *error = NULL;
d1d875
       uint8_t pixels[6];
d1d875
       int width, height;
d1d875
 
d1d875
@@ -555,7 +557,13 @@ ensure_color_texture (MetaBackground *self)
d1d875
                                                                          COGL_PIXEL_FORMAT_RGB_888,
d1d875
                                                                          width * 3,
d1d875
                                                                          pixels,
d1d875
-                                                                         NULL));
d1d875
+                                                                         &error));
d1d875
+
d1d875
+      if (error != NULL)
d1d875
+        {
d1d875
+          meta_warning ("Failed to allocate color texture: %s\n", error->message);
d1d875
+          cogl_error_free (error);
d1d875
+        }
d1d875
     }
d1d875
 }
d1d875
 
d1d875
diff --git a/src/compositor/meta-shadow-factory.c b/src/compositor/meta-shadow-factory.c
d1d875
index 0a60398..b2c5a1e 100644
d1d875
--- a/src/compositor/meta-shadow-factory.c
d1d875
+++ b/src/compositor/meta-shadow-factory.c
d1d875
@@ -26,6 +26,7 @@
d1d875
 #include <math.h>
d1d875
 #include <string.h>
d1d875
 
d1d875
+#include <meta/util.h>
d1d875
 #include "cogl-utils.h"
d1d875
 #include "meta-shadow-factory-private.h"
d1d875
 #include "region-utils.h"
d1d875
@@ -706,6 +707,7 @@ make_shadow (MetaShadow     *shadow,
d1d875
 {
d1d875
   ClutterBackend *backend = clutter_get_default_backend ();
d1d875
   CoglContext *ctx = clutter_backend_get_cogl_context (backend);
d1d875
+  CoglError *error = NULL;
d1d875
   int d = get_box_filter_size (shadow->key.radius);
d1d875
   int spread = get_shadow_spread (shadow->key.radius);
d1d875
   cairo_rectangle_int_t extents;
d1d875
@@ -803,7 +805,13 @@ make_shadow (MetaShadow     *shadow,
d1d875
                                                                  (buffer +
d1d875
                                                                   (y_offset - shadow->outer_border_top) * buffer_width +
d1d875
                                                                   (x_offset - shadow->outer_border_left)),
d1d875
-                                                                 NULL));
d1d875
+                                                                 &error));
d1d875
+
d1d875
+  if (error)
d1d875
+    {
d1d875
+      meta_warning ("Failed to allocate shadow texture: %s\n", error->message);
d1d875
+      cogl_error_free (error);
d1d875
+    }
d1d875
 
d1d875
   cairo_region_destroy (row_convolve_region);
d1d875
   cairo_region_destroy (column_convolve_region);
d1d875
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
d1d875
index 4a5ac00..62f517b 100644
d1d875
--- a/src/compositor/meta-surface-actor-x11.c
d1d875
+++ b/src/compositor/meta-surface-actor-x11.c
d1d875
@@ -113,14 +113,20 @@ set_pixmap (MetaSurfaceActorX11 *self,
d1d875
 
d1d875
   CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
d1d875
   MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self));
d1d875
+  CoglError *error = NULL;
d1d875
   CoglTexture *texture;
d1d875
 
d1d875
   g_assert (priv->pixmap == None);
d1d875
   priv->pixmap = pixmap;
d1d875
 
d1d875
-  texture = COGL_TEXTURE (cogl_texture_pixmap_x11_new (ctx, priv->pixmap, FALSE, NULL));
d1d875
+  texture = COGL_TEXTURE (cogl_texture_pixmap_x11_new (ctx, priv->pixmap, FALSE, &error));
d1d875
 
d1d875
-  if (G_UNLIKELY (!cogl_texture_pixmap_x11_is_using_tfp_extension (COGL_TEXTURE_PIXMAP_X11 (texture))))
d1d875
+  if (error != NULL)
d1d875
+    {
d1d875
+      g_warning ("Failed to allocate stex texture: %s", error->message);
d1d875
+      cogl_error_free (error);
d1d875
+    }
d1d875
+  else if (G_UNLIKELY (!cogl_texture_pixmap_x11_is_using_tfp_extension (COGL_TEXTURE_PIXMAP_X11 (texture))))
d1d875
     g_warning ("NOTE: Not using GLX TFP!\n");
d1d875
 
d1d875
   priv->texture = texture;
d1d875
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
d1d875
index 476abbf..edc21e3 100644
d1d875
--- a/src/compositor/meta-window-actor.c
d1d875
+++ b/src/compositor/meta-window-actor.c
d1d875
@@ -1791,9 +1791,17 @@ build_and_scan_frame_mask (MetaWindowActor       *self,
d1d875
     }
d1d875
   else
d1d875
     {
d1d875
+      CoglError *error = NULL;
d1d875
+
d1d875
       mask_texture = COGL_TEXTURE (cogl_texture_2d_new_from_data (ctx, tex_width, tex_height,
d1d875
                                                                   COGL_PIXEL_FORMAT_A_8,
d1d875
-                                                                  stride, mask_data, NULL));
d1d875
+                                                                  stride, mask_data, &error));
d1d875
+
d1d875
+      if (error)
d1d875
+        {
d1d875
+          g_warning ("Failed to allocate mask texture: %s", error->message);
d1d875
+          cogl_error_free (error);
d1d875
+        }
d1d875
     }
d1d875
 
d1d875
   meta_shaped_texture_set_mask_texture (stex, mask_texture);
d1d875
diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c
d1d875
index 40db3b0..eda2326 100644
d1d875
--- a/src/wayland/meta-wayland-buffer.c
d1d875
+++ b/src/wayland/meta-wayland-buffer.c
d1d875
@@ -131,7 +131,13 @@ meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
d1d875
           cogl_wayland_texture_set_region_from_shm_buffer (buffer->texture,
d1d875
                                                            rect.x, rect.y, rect.width, rect.height,
d1d875
                                                            shm_buffer,
d1d875
-                                                           rect.x, rect.y, 0, NULL);
d1d875
+                                                           rect.x, rect.y, 0, &error);
d1d875
+
d1d875
+          if (error)
d1d875
+            {
d1d875
+              meta_warning ("Failed to set texture region: %s\n", error->message);
d1d875
+              cogl_error_free (error);
d1d875
+            }
d1d875
         }
d1d875
     }
d1d875
 }
d1d875
-- 
d1d875
2.7.3
d1d875