x11-display: Use autoptr during construction

This simplifies error paths, as they don't need to unref.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
This commit is contained in:
Jonas Ådahl 2022-04-06 11:32:51 +02:00 committed by Marge Bot
parent 28cbc213d0
commit ecaf091eb4

View File

@ -1127,7 +1127,7 @@ meta_x11_display_new (MetaDisplay *display,
GError **error) GError **error)
{ {
MetaContext *context = meta_display_get_context (display); MetaContext *context = meta_display_get_context (display);
MetaX11Display *x11_display; g_autoptr (MetaX11Display) x11_display = NULL;
Display *xdisplay; Display *xdisplay;
Screen *xscreen; Screen *xscreen;
Window xroot; Window xroot;
@ -1399,8 +1399,6 @@ meta_x11_display_new (MetaDisplay *display,
"Failed to acquire window manager ownership"); "Failed to acquire window manager ownership");
g_object_run_dispose (G_OBJECT (x11_display)); g_object_run_dispose (G_OBJECT (x11_display));
g_clear_object (&x11_display);
return NULL; return NULL;
} }
@ -1410,7 +1408,7 @@ meta_x11_display_new (MetaDisplay *display,
init_event_masks (x11_display); init_event_masks (x11_display);
return x11_display; return g_steal_pointer (&x11_display);
} }
void void