[grilo/wip/hadess/network-sources-crasher: 1/3] registry: Fix source refcount when using source-{added, removed}
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo/wip/hadess/network-sources-crasher: 1/3] registry: Fix source refcount when using source-{added, removed}
- Date: Fri, 16 Nov 2018 12:41:14 +0000 (UTC)
commit aeaf95888a9feaefeeb159a13bdf987a8e4f0bf5
Author: Bastien Nocera <hadess hadess net>
Date: Fri Nov 16 12:31:37 2018 +0100
registry: Fix source refcount when using source-{added,removed}
Both of those signals expect a GObject to be passed, and will unref the
object before returning from the signal emission. As we didn't add a
reference to the source we passed, this callback might remove the last
reference to the source, and finalize it.
This fixes a crash on startup in Totem.
See https://github.com/flathub/org.gnome.Totem/issues/6
src/grl-registry.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/grl-registry.c b/src/grl-registry.c
index 4124ddd..64ed193 100644
--- a/src/grl-registry.c
+++ b/src/grl-registry.c
@@ -241,7 +241,7 @@ network_changed_cb (GObject *gobject,
GRL_DEBUG ("Network isn't available for '%s', hiding",
grl_source_get_id (current_source));
SET_INVISIBLE_SOURCE(current_source, TRUE);
- g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, current_source);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, g_object_ref (current_source));
}
}
} else {
@@ -257,7 +257,7 @@ network_changed_cb (GObject *gobject,
GRL_DEBUG ("Local network became available for '%s', showing",
grl_source_get_id (current_source));
SET_INVISIBLE_SOURCE(current_source, FALSE);
- g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, current_source);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, g_object_ref (current_source));
}
if (g_strv_contains (tags, INTERNET_NET_TAG) &&
@@ -266,7 +266,7 @@ network_changed_cb (GObject *gobject,
GRL_DEBUG ("Internet became available for '%s', showing",
grl_source_get_id (current_source));
SET_INVISIBLE_SOURCE(current_source, FALSE);
- g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, current_source);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, g_object_ref (current_source));
}
if (g_strv_contains (tags, INTERNET_NET_TAG) &&
@@ -275,7 +275,7 @@ network_changed_cb (GObject *gobject,
GRL_DEBUG ("Internet became unavailable for '%s', hiding",
grl_source_get_id (current_source));
SET_INVISIBLE_SOURCE(current_source, TRUE);
- g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, current_source);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, g_object_ref (current_source));
}
}
}
@@ -1017,7 +1017,7 @@ grl_registry_register_source (GrlRegistry *registry,
update_source_visibility (registry, source);
if (!SOURCE_IS_INVISIBLE(source))
- g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, source);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, g_object_ref (source));
return TRUE;
}
@@ -1050,7 +1050,7 @@ grl_registry_unregister_source (GrlRegistry *registry,
if (g_hash_table_remove (registry->priv->sources, id)) {
GRL_DEBUG ("source '%s' is no longer available", id);
- g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, source);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, g_object_ref (source));
g_object_unref (source);
} else {
GRL_WARNING ("source '%s' not found", id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]