1
0
Fork 0

stage-view: Add clutter_stage_view_destroy()

This aims to make sure a view and its resources are destroyed when it
should. Using references might keep certain components (e.g frame clock)
alive for too long.

We currently don't take any long lived references to the stage view
anywhere, so this doesn't matter in practice, but this may change, and
will be used by a to be added test case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1404
This commit is contained in:
Jonas Ådahl 2020-08-12 15:28:34 +02:00
parent a13c307fa4
commit fb0f03640a
4 changed files with 15 additions and 5 deletions

View file

@ -86,6 +86,13 @@ typedef struct _ClutterStageViewPrivate
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageView, clutter_stage_view, G_TYPE_OBJECT)
void
clutter_stage_view_destroy (ClutterStageView *view)
{
g_object_run_dispose (G_OBJECT (view));
g_object_unref (view);
}
void
clutter_stage_view_get_layout (ClutterStageView *view,
cairo_rectangle_int_t *rect)

View file

@ -52,6 +52,9 @@ struct _ClutterStageViewClass
cairo_rectangle_int_t *dst_rect);
};
CLUTTER_EXPORT
void clutter_stage_view_destroy (ClutterStageView *view);
CLUTTER_EXPORT
void clutter_stage_view_get_layout (ClutterStageView *view,
cairo_rectangle_int_t *rect);

View file

@ -773,16 +773,16 @@ on_framebuffer_set (ClutterStageView *view)
}
static void
clutter_stage_view_cogl_finalize (GObject *object)
clutter_stage_view_cogl_dispose (GObject *object)
{
ClutterStageViewCogl *view_cogl = CLUTTER_STAGE_VIEW_COGL (object);
ClutterStageViewCoglPrivate *view_priv =
clutter_stage_view_cogl_get_instance_private (view_cogl);
g_clear_handle_id (&view_priv->notify_presented_handle_id, g_source_remove);
clutter_damage_history_free (view_priv->damage_history);
g_clear_pointer (&view_priv->damage_history, clutter_damage_history_free);
G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->finalize (object);
G_OBJECT_CLASS (clutter_stage_view_cogl_parent_class)->dispose (object);
}
static void
@ -802,5 +802,5 @@ clutter_stage_view_cogl_class_init (ClutterStageViewCoglClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = clutter_stage_view_cogl_finalize;
object_class->dispose = clutter_stage_view_cogl_dispose;
}

View file

@ -143,7 +143,7 @@ meta_renderer_real_rebuild_views (MetaRenderer *renderer)
meta_backend_get_monitor_manager (backend);
GList *logical_monitors, *l;
g_list_free_full (priv->views, g_object_unref);
g_list_free_full (priv->views, (GDestroyNotify) clutter_stage_view_destroy);
priv->views = NULL;
logical_monitors =