placesview: keep reference during network fetching

Analogous to (un)mount operation, we now keep a reference around
during the ongoing operation and make use of the destroyed flag
to check if we are still alive or if we have been cancelled as
a result of the widget being destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=764979
This commit is contained in:
Christian Kellner 2016-09-05 13:41:16 +02:00 committed by Matthias Clasen
parent 7cdc04c8d2
commit d4bf215611

View File

@ -970,8 +970,11 @@ network_enumeration_next_files_finished (GObject *source_object,
g_list_free_full (detected_networks, g_object_unref); g_list_free_full (detected_networks, g_object_unref);
} }
/* avoid to update widgets if the operation was cancelled in finalize */ g_object_unref (view);
if (priv->listbox != NULL)
/* avoid to update widgets if we are already destroyed
(and got cancelled s a result of that) */
if (!priv->destroyed)
{ {
update_network_state (view); update_network_state (view);
update_loading (view); update_loading (view);
@ -997,6 +1000,7 @@ network_enumeration_finished (GObject *source_object,
g_warning ("Failed to fetch network locations: %s", error->message); g_warning ("Failed to fetch network locations: %s", error->message);
g_clear_error (&error); g_clear_error (&error);
g_object_unref (GTK_PLACES_VIEW (user_data));
} }
else else
{ {
@ -1036,6 +1040,7 @@ fetch_networks (GtkPlacesView *view)
gtk_places_view_set_fetching_networks (view, TRUE); gtk_places_view_set_fetching_networks (view, TRUE);
update_network_state (view); update_network_state (view);
g_object_ref (view);
g_file_enumerate_children_async (network_file, g_file_enumerate_children_async (network_file,
"standard::type,standard::target-uri,standard::name,standard::display-name,standard::icon", "standard::type,standard::target-uri,standard::name,standard::display-name,standard::icon",
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,