From e16e66de2d80a448fe356e259a0a12796b11f215 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Fri, 26 Apr 2019 13:19:18 +0300 Subject: [PATCH] lib: object/interface: do not (transfer full) interfaces and objects --- lib/wp/interface-impl.c | 6 +++--- lib/wp/object.c | 4 ++-- lib/wp/plugin.c | 2 +- lib/wp/proxy.c | 2 +- modules/module-default-session.c | 12 ++++++------ src/core.c | 6 +++--- src/plugin-registry-impl.c | 4 +--- src/proxy-registry-impl.c | 5 ++--- src/session-registry-impl.c | 4 ++-- 9 files changed, 21 insertions(+), 24 deletions(-) diff --git a/lib/wp/interface-impl.c b/lib/wp/interface-impl.c index 25de7840..ec2ce88d 100644 --- a/lib/wp/interface-impl.c +++ b/lib/wp/interface-impl.c @@ -75,20 +75,20 @@ wp_interface_impl_get_object (WpInterfaceImpl * self) * @self: the interface implementation instance * @interface: an interface type * - * Returns: (type GObject*) (nullable) (transfer full): the object + * Returns: (type GObject*) (nullable) (transfer none): the object * implementing @interface */ gpointer wp_interface_impl_get_sibling (WpInterfaceImpl * self, GType interface) { WpInterfaceImplPrivate *priv = wp_interface_impl_get_instance_private (self); - GObject *iface = NULL; + gpointer iface = NULL; g_return_val_if_fail (WP_IS_INTERFACE_IMPL (self), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL); if (g_type_is_a (G_TYPE_FROM_INSTANCE (self), interface)) { - iface = G_OBJECT (g_object_ref (self)); + iface = self; } else if (priv->object) { iface = wp_object_get_interface (priv->object, interface); } diff --git a/lib/wp/object.c b/lib/wp/object.c index 53c58ec3..c25d535c 100644 --- a/lib/wp/object.c +++ b/lib/wp/object.c @@ -94,7 +94,7 @@ wp_object_implements_interface (WpObject * self, GType interface) * @self: the object * @interface: an interface type * - * Returns: (type GObject*) (nullable) (transfer full): the object + * Returns: (type GObject*) (nullable) (transfer none): the object * implementing @interface */ gpointer @@ -108,7 +108,7 @@ wp_object_get_interface (WpObject * self, GType interface) for (i = 0; i < priv->iface_objects->len; i++) { GObject *obj = g_array_index (priv->iface_objects, GObject*, i); if (g_type_is_a (G_TYPE_FROM_INSTANCE (obj), interface)) - return g_object_ref (obj); + return obj; } return NULL; diff --git a/lib/wp/plugin.c b/lib/wp/plugin.c index 9a6c8bac..5c80981e 100644 --- a/lib/wp/plugin.c +++ b/lib/wp/plugin.c @@ -117,8 +117,8 @@ default_handle_pw_proxy (WpPlugin * self, WpProxy * proxy) case PW_TYPE_INTERFACE_Node: { + WpProxyRegistry *reg; g_autoptr (WpProxy) parent; - g_autoptr (WpProxyRegistry) reg; reg = wp_object_get_interface (priv->core, WP_TYPE_PROXY_REGISTRY); parent = wp_proxy_registry_get_proxy (reg, wp_proxy_get_parent_id (proxy)); diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c index e199bc83..c8ae45fe 100644 --- a/lib/wp/proxy.c +++ b/lib/wp/proxy.c @@ -223,7 +223,7 @@ static void wp_proxy_constructed (GObject * object) { WpProxy *self = WP_PROXY (object); - g_autoptr (WpProxyRegistry) pr = NULL; + WpProxyRegistry *pr = NULL; struct pw_registry_proxy *reg_proxy; const void *events = NULL; uint32_t ver = 0; diff --git a/modules/module-default-session.c b/modules/module-default-session.c index c9f0ebac..703e9a6e 100644 --- a/modules/module-default-session.c +++ b/modules/module-default-session.c @@ -78,7 +78,7 @@ static void device_node_destroyed (WpProxy * device_node, DefaultSession * session) { g_autoptr (WpObject) core = NULL; - g_autoptr (WpSessionRegistry) sr = NULL; + WpSessionRegistry *sr = NULL; g_info ("Proxy %u destroyed - unregistering session %u", wp_proxy_get_id (device_node), session->session_id); @@ -94,9 +94,9 @@ static gboolean handle_node (WpPlugin * self, WpProxy * proxy) { g_autoptr (WpObject) core = NULL; - g_autoptr (WpSessionRegistry) sr = NULL; - g_autoptr (GError) error = NULL; g_autoptr (DefaultSession) session = NULL; + g_autoptr (GError) error = NULL; + WpSessionRegistry *sr = NULL; const gchar *media_class, *ptr; WpSessionDirection direction; guint32 media_type; @@ -158,9 +158,9 @@ plug_dsp (WpProxy * node) { DefaultSession *session; g_autoptr (WpObject) core = NULL; - g_autoptr (WpPipewireObjects) pw_objects = NULL; + WpPipewireObjects *pw_objects = NULL; struct pw_core_proxy *core_proxy; - g_autoptr (WpPipewireProperties) pw_props = NULL; + WpPipewireProperties *pw_props = NULL; struct pw_properties *props; const char *name; enum pw_direction reverse_direction; @@ -273,7 +273,7 @@ handle_pw_proxy (WpPlugin * self, WpProxy * proxy) { g_autoptr (WpObject) core = NULL; g_autoptr (WpProxy) parent = NULL; - g_autoptr (WpProxyRegistry) reg = NULL; + WpProxyRegistry *reg = NULL; DefaultSession *session; if (wp_proxy_get_spa_type (proxy) != PW_TYPE_INTERFACE_Port && diff --git a/src/core.c b/src/core.c index 36b99029..9a83455e 100644 --- a/src/core.c +++ b/src/core.c @@ -85,7 +85,7 @@ static gboolean wp_core_parse_commands_file (WpCore * self, GInputStream * stream, GError ** error) { - g_autoptr (WpPluginRegistry) plugin_registry = NULL; + WpPluginRegistry *plugin_registry = NULL; gchar buffer[4096]; gssize bytes_read; gchar *cur, *linestart, *saveptr; @@ -231,8 +231,8 @@ static void wp_core_dispose (GObject * obj) { WpCore *self = WP_CORE (obj); - g_autoptr (WpPluginRegistry) plugin_registry = NULL; - g_autoptr (WpProxyRegistry) proxy_registry = NULL; + WpPluginRegistry *plugin_registry = NULL; + WpProxyRegistry *proxy_registry = NULL; /* ensure all proxies and plugins are unrefed, * so that the registries can be disposed */ diff --git a/src/plugin-registry-impl.c b/src/plugin-registry-impl.c index f0bc36a7..2e713882 100644 --- a/src/plugin-registry-impl.c +++ b/src/plugin-registry-impl.c @@ -139,9 +139,7 @@ wp_plugin_registry_impl_unload (WpPluginRegistryImpl * self) static inline void make_plugin (WpPluginRegistryImpl * self, PluginData * plugin_data) { - g_autoptr (WpObject) core = - wp_interface_impl_get_object (WP_INTERFACE_IMPL (self)); - + WpObject *core = wp_interface_impl_get_object (WP_INTERFACE_IMPL (self)); plugin_data->instance = g_object_new (plugin_data->gtype, "core", core, "metadata", plugin_data->metadata, NULL); } diff --git a/src/proxy-registry-impl.c b/src/proxy-registry-impl.c index b0f60a7c..3ad0770a 100644 --- a/src/proxy-registry-impl.c +++ b/src/proxy-registry-impl.c @@ -88,9 +88,8 @@ registry_global (void * data, uint32_t id, uint32_t parent_id, { WpProxyRegistryImpl *self = WP_PROXY_REGISTRY_IMPL (data); WpProxy *proxy; - g_autoptr (WpPluginRegistry) plugin_registry = NULL; - g_autoptr (WpObject) core = - wp_interface_impl_get_object (WP_INTERFACE_IMPL (self)); + WpPluginRegistry *plugin_registry = NULL; + WpObject *core = wp_interface_impl_get_object (WP_INTERFACE_IMPL (self)); proxy = g_object_new (WP_TYPE_PROXY, "id", id, diff --git a/src/session-registry-impl.c b/src/session-registry-impl.c index 98686055..e1a1713a 100644 --- a/src/session-registry-impl.c +++ b/src/session-registry-impl.c @@ -104,8 +104,8 @@ register_session (WpSessionRegistry * sr, GError ** error) { WpSessionRegistryImpl * self = WP_SESSION_REGISTRY_IMPL (sr); - g_autoptr (WpPluginRegistry) plugin_registry = NULL; - g_autoptr (WpPipewireProperties) pw_props = NULL; + WpPluginRegistry *plugin_registry = NULL; + WpPipewireProperties *pw_props = NULL; const gchar *media_class = NULL; SessionData data;