user-accounts: Fix a critical warning if loading a cursor fails

It’s possible for `gdk_cursor_new_for_display()` to return `NULL`. It’s
OK to pass `NULL` to `gdk_window_set_cursor()`, but not OK to then unref
it.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2020-09-29 14:58:47 +01:00 committed by Robert Ancell
parent 7bbbef5fde
commit 243ff6a511

View file

@ -352,10 +352,10 @@ update_cursor (CcCropArea *area,
} }
if (cursor_type != area->current_cursor) { if (cursor_type != area->current_cursor) {
GdkCursor *cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (area)), g_autoptr(GdkCursor) cursor = NULL;
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (area)),
cursor_type); cursor_type);
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (area)), cursor); gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (area)), cursor);
g_object_unref (cursor);
area->current_cursor = cursor_type; area->current_cursor = cursor_type;
} }
} }