thread: Initialize using GInitable
To later add error handling. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2777>
This commit is contained in:
parent
a6baa77eab
commit
7277592255
@ -455,7 +455,8 @@ meta_kms_new (MetaBackend *backend,
|
|||||||
MetaUdev *udev = meta_backend_native_get_udev (backend_native);
|
MetaUdev *udev = meta_backend_native_get_udev (backend_native);
|
||||||
MetaKms *kms;
|
MetaKms *kms;
|
||||||
|
|
||||||
kms = g_object_new (META_TYPE_KMS,
|
kms = g_initable_new (META_TYPE_KMS,
|
||||||
|
NULL, error,
|
||||||
"backend", backend,
|
"backend", backend,
|
||||||
NULL);
|
NULL);
|
||||||
kms->flags = flags;
|
kms->flags = flags;
|
||||||
|
@ -79,8 +79,12 @@ typedef struct _MetaThreadClassPrivate
|
|||||||
GType impl_type;
|
GType impl_type;
|
||||||
} MetaThreadClassPrivate;
|
} MetaThreadClassPrivate;
|
||||||
|
|
||||||
|
static void initable_iface_init (GInitableIface *initable_iface);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (MetaThread, meta_thread, G_TYPE_OBJECT,
|
G_DEFINE_TYPE_WITH_CODE (MetaThread, meta_thread, G_TYPE_OBJECT,
|
||||||
G_ADD_PRIVATE (MetaThread)
|
G_ADD_PRIVATE (MetaThread)
|
||||||
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
||||||
|
initable_iface_init)
|
||||||
g_type_add_class_private (g_define_type_id,
|
g_type_add_class_private (g_define_type_id,
|
||||||
sizeof (MetaThreadClassPrivate)))
|
sizeof (MetaThreadClassPrivate)))
|
||||||
|
|
||||||
@ -132,24 +136,32 @@ meta_thread_set_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
meta_thread_constructed (GObject *object)
|
meta_thread_initable_init (GInitable *initable,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
MetaThread *thread = META_THREAD (object);
|
MetaThread *thread = META_THREAD (initable);
|
||||||
MetaThreadPrivate *priv = meta_thread_get_instance_private (thread);
|
MetaThreadPrivate *priv = meta_thread_get_instance_private (thread);
|
||||||
MetaThreadClass *thread_class = META_THREAD_GET_CLASS (thread);
|
MetaThreadClass *thread_class = META_THREAD_GET_CLASS (thread);
|
||||||
MetaThreadClassPrivate *class_priv =
|
MetaThreadClassPrivate *class_priv =
|
||||||
G_TYPE_CLASS_GET_PRIVATE (thread_class, META_TYPE_THREAD,
|
G_TYPE_CLASS_GET_PRIVATE (thread_class, META_TYPE_THREAD,
|
||||||
MetaThreadClassPrivate);
|
MetaThreadClassPrivate);
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_thread_parent_class)->constructed (object);
|
|
||||||
|
|
||||||
priv->main_context = g_main_context_get_thread_default ();
|
priv->main_context = g_main_context_get_thread_default ();
|
||||||
|
|
||||||
g_assert (g_type_is_a (class_priv->impl_type, META_TYPE_THREAD_IMPL));
|
g_assert (g_type_is_a (class_priv->impl_type, META_TYPE_THREAD_IMPL));
|
||||||
priv->impl = g_object_new (class_priv->impl_type,
|
priv->impl = g_object_new (class_priv->impl_type,
|
||||||
"thread", thread,
|
"thread", thread,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
initable_iface_init (GInitableIface *initable_iface)
|
||||||
|
{
|
||||||
|
initable_iface->init = meta_thread_initable_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -174,7 +186,6 @@ meta_thread_class_init (MetaThreadClass *klass)
|
|||||||
|
|
||||||
object_class->get_property = meta_thread_get_property;
|
object_class->get_property = meta_thread_get_property;
|
||||||
object_class->set_property = meta_thread_set_property;
|
object_class->set_property = meta_thread_set_property;
|
||||||
object_class->constructed = meta_thread_constructed;
|
|
||||||
object_class->finalize = meta_thread_finalize;
|
object_class->finalize = meta_thread_finalize;
|
||||||
|
|
||||||
obj_props[PROP_BACKEND] =
|
obj_props[PROP_BACKEND] =
|
||||||
|
Loading…
Reference in New Issue
Block a user