[grilo/wip/hadess/network-sources-crasher: 3/3] registry: Fix possible crasher on startup in Totem
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo/wip/hadess/network-sources-crasher: 3/3] registry: Fix possible crasher on startup in Totem
- Date: Fri, 16 Nov 2018 13:43:15 +0000 (UTC)
commit 79b36bc51aafebfb1f2e91ee4111bab948a29333
Author: Bastien Nocera <hadess hadess net>
Date: Fri Nov 16 14:38:58 2018 +0100
registry: Fix possible crasher on startup in Totem
When announcing that a source was added, the application might choose to
say "actually, I'm not interested in this source" and unref it. As we
want to be able to carry on checking some of its properties, such as
tags, we either need to check whether the source was finalized in
between calls, or keep a list of sources to be added/removed after we've
done computation.
The latter is easier to implement, so add all sources to temporary lists
to avoid the tags disappearing from under us when emitting the signals.
See https://github.com/flathub/org.gnome.Totem/issues/6
src/grl-registry.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/grl-registry.c b/src/grl-registry.c
index c03be54..2aedfa5 100644
--- a/src/grl-registry.c
+++ b/src/grl-registry.c
@@ -250,6 +250,10 @@ network_changed_cb (GObject *gobject,
}
}
} else {
+ GList *to_add, *to_remove;
+
+ to_add = to_remove = NULL;
+
for (l = sources; l != NULL; l = l->next) {
const char **tags;
@@ -263,8 +267,7 @@ network_changed_cb (GObject *gobject,
SOURCE_IS_INVISIBLE(current_source)) {
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);
+ to_add = g_list_prepend (to_add, current_source);
}
if (g_strv_contains (tags, INTERNET_NET_TAG) &&
@@ -272,8 +275,7 @@ network_changed_cb (GObject *gobject,
SOURCE_IS_INVISIBLE(current_source)) {
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);
+ to_add = g_list_prepend (to_add, current_source);
}
if (g_strv_contains (tags, INTERNET_NET_TAG) &&
@@ -281,10 +283,21 @@ network_changed_cb (GObject *gobject,
!SOURCE_IS_INVISIBLE(current_source)) {
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);
+ to_remove = g_list_prepend (to_remove, current_source);
}
}
+
+ for (l = to_add; l != NULL; l = l->next) {
+ SET_INVISIBLE_SOURCE(l->data, FALSE);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, l->data);
+ }
+ g_list_free (to_add);
+
+ for (l = to_remove; l != NULL; l = l->next) {
+ SET_INVISIBLE_SOURCE(l->data, TRUE);
+ g_signal_emit (registry, registry_signals[SIG_SOURCE_REMOVED], 0, l->data);
+ }
+ g_list_free (to_remove);
}
g_list_free (sources);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]