mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-03 17:21:11 +00:00
gtkplacesview: bail out if operation cancelled
When an operation is cancelled it's never safe to access the object itself or the private struct, since it could be called (and probably is) during finalize. In case the operation is cancelled, just bail out to fix the crashes.
This commit is contained in:
parent
232ab9d30d
commit
00b17651b1
@ -1145,21 +1145,11 @@ server_mount_ready_cb (GObject *source_file,
|
||||
GError *error;
|
||||
GFile *location;
|
||||
|
||||
view = GTK_PLACES_VIEW (user_data);
|
||||
priv = gtk_places_view_get_instance_private (view);
|
||||
location = G_FILE (source_file);
|
||||
should_show = TRUE;
|
||||
error = NULL;
|
||||
|
||||
priv->should_pulse_entry = FALSE;
|
||||
set_busy_cursor (view, FALSE);
|
||||
|
||||
g_file_mount_enclosing_volume_finish (location, res, &error);
|
||||
/* Restore from Cancel to Connect */
|
||||
gtk_button_set_label (GTK_BUTTON (priv->connect_button), _("Con_nect"));
|
||||
gtk_widget_set_sensitive (priv->address_entry, TRUE);
|
||||
priv->connecting_to_server = FALSE;
|
||||
|
||||
if (error)
|
||||
{
|
||||
should_show = FALSE;
|
||||
@ -1176,14 +1166,30 @@ server_mount_ready_cb (GObject *source_file,
|
||||
(error->code != G_IO_ERROR_CANCELLED &&
|
||||
error->code != G_IO_ERROR_FAILED_HANDLED))
|
||||
{
|
||||
view = GTK_PLACES_VIEW (user_data);
|
||||
/* if it wasn't cancelled show a dialog */
|
||||
emit_show_error_message (view, _("Unable to access location"), error->message);
|
||||
should_show = FALSE;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* it was cancelled, so probably it was called during finalize, bail out. */
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
view = GTK_PLACES_VIEW (user_data);
|
||||
priv = gtk_places_view_get_instance_private (view);
|
||||
priv->should_pulse_entry = FALSE;
|
||||
set_busy_cursor (view, FALSE);
|
||||
|
||||
/* Restore from Cancel to Connect */
|
||||
gtk_button_set_label (GTK_BUTTON (priv->connect_button), _("Con_nect"));
|
||||
gtk_widget_set_sensitive (priv->address_entry, TRUE);
|
||||
priv->connecting_to_server = FALSE;
|
||||
|
||||
if (should_show)
|
||||
{
|
||||
server_list_add_server (view, location);
|
||||
@ -1234,14 +1240,10 @@ volume_mount_ready_cb (GObject *source_volume,
|
||||
GVolume *volume;
|
||||
GError *error;
|
||||
|
||||
view = GTK_PLACES_VIEW (user_data);
|
||||
priv = gtk_places_view_get_instance_private (view);
|
||||
volume = G_VOLUME (source_volume);
|
||||
should_show = TRUE;
|
||||
error = NULL;
|
||||
|
||||
set_busy_cursor (view, FALSE);
|
||||
|
||||
g_volume_mount_finish (volume, res, &error);
|
||||
|
||||
if (error)
|
||||
@ -1264,10 +1266,20 @@ volume_mount_ready_cb (GObject *source_volume,
|
||||
emit_show_error_message (GTK_PLACES_VIEW (user_data), _("Unable to access location"), error->message);
|
||||
should_show = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* it was cancelled, so probably it was called during finalize, bail out. */
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
view = GTK_PLACES_VIEW (user_data);
|
||||
priv = gtk_places_view_get_instance_private (view);
|
||||
set_busy_cursor (view, FALSE);
|
||||
|
||||
if (should_show)
|
||||
{
|
||||
GMount *mount;
|
||||
|
Loading…
Reference in New Issue
Block a user