[mutter/wayland] cursor-tracker: Make ensure_wayland_cursor take a ref



commit 73a908206229473c0cc9a34eeb7681ffba2c03f5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Nov 18 19:47:34 2013 -0500

    cursor-tracker: Make ensure_wayland_cursor take a ref
    
    This fixes a crash in the last commit because that's what I thought
    this would do.
    
    It also simplifies callers drastically...

 src/core/meta-cursor-tracker.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c
index bbdba90..eda4cd9 100644
--- a/src/core/meta-cursor-tracker.c
+++ b/src/core/meta-cursor-tracker.c
@@ -822,14 +822,14 @@ static MetaCursorReference *
 ensure_wayland_cursor (MetaCursorTracker *tracker,
                        MetaCursor         cursor)
 {
-  if (tracker->default_cursors[cursor])
-    return tracker->default_cursors[cursor];
-
-  tracker->default_cursors[cursor] = meta_cursor_reference_from_theme (tracker, cursor);
   if (!tracker->default_cursors[cursor])
-    meta_warning ("Failed to load cursor from theme\n");
+    {
+      tracker->default_cursors[cursor] = meta_cursor_reference_from_theme (tracker, cursor);
+      if (!tracker->default_cursors[cursor])
+        meta_warning ("Failed to load cursor from theme\n");
+    }
 
-  return tracker->default_cursors[cursor];
+  return meta_cursor_reference_ref (tracker->default_cursors[cursor]);
 }
 
 void
@@ -880,12 +880,8 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
   /* Now update the real root cursor */
   if (meta_is_wayland_compositor ())
     {
-      MetaCursorReference *ref;
-
-      ref = ensure_wayland_cursor (tracker, cursor);
-
       g_clear_pointer (&tracker->root_cursor, meta_cursor_reference_unref);
-      tracker->root_cursor = meta_cursor_reference_ref (ref);
+      tracker->root_cursor = ensure_wayland_cursor (tracker, cursor);
     }
 }
 


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