From 73a908206229473c0cc9a34eeb7681ffba2c03f5 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 18 Nov 2013 19:47:34 -0500 Subject: [PATCH] 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 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c index bbdba907a..eda4cd99d 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); } }