mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-06-30 23:46:35 +00:00
files-view: Prevent use-after-free with mount and stop
Unmount and eject are already doing this since commit 80dd8fb8ff
Let's do the same for mount and stop, and use g_autoptr() to emphasize
the callback taking ownership of the reference passed to the method.
This commit is contained in:
parent
da79c2f3bf
commit
c674046e29
|
@ -6828,9 +6828,7 @@ file_mount_callback (NautilusFile *file,
|
|||
GError *error,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NautilusFilesView *view;
|
||||
|
||||
view = NAUTILUS_FILES_VIEW (callback_data);
|
||||
g_autoptr (NautilusFilesView) self = NAUTILUS_FILES_VIEW (callback_data);
|
||||
|
||||
nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_MOUNT);
|
||||
|
||||
|
@ -6845,7 +6843,7 @@ file_mount_callback (NautilusFile *file,
|
|||
nautilus_file_get_display_name (file));
|
||||
show_dialog (text,
|
||||
error->message,
|
||||
GTK_WINDOW (nautilus_files_view_get_window (view)),
|
||||
GTK_WINDOW (nautilus_files_view_get_window (self)),
|
||||
GTK_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -6856,10 +6854,7 @@ file_unmount_callback (NautilusFile *file,
|
|||
GError *error,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NautilusFilesView *view;
|
||||
|
||||
view = NAUTILUS_FILES_VIEW (callback_data);
|
||||
g_object_unref (view);
|
||||
g_autoptr (NautilusFilesView) self = NAUTILUS_FILES_VIEW (callback_data);
|
||||
|
||||
if (error != NULL &&
|
||||
(error->domain != G_IO_ERROR ||
|
||||
|
@ -6871,7 +6866,7 @@ file_unmount_callback (NautilusFile *file,
|
|||
nautilus_file_get_display_name (file));
|
||||
show_dialog (text,
|
||||
error->message,
|
||||
GTK_WINDOW (nautilus_files_view_get_window (view)),
|
||||
GTK_WINDOW (nautilus_files_view_get_window (self)),
|
||||
GTK_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -6882,10 +6877,7 @@ file_eject_callback (NautilusFile *file,
|
|||
GError *error,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NautilusFilesView *view;
|
||||
|
||||
view = NAUTILUS_FILES_VIEW (callback_data);
|
||||
g_object_unref (view);
|
||||
g_autoptr (NautilusFilesView) self = NAUTILUS_FILES_VIEW (callback_data);
|
||||
|
||||
if (error != NULL &&
|
||||
(error->domain != G_IO_ERROR ||
|
||||
|
@ -6897,7 +6889,7 @@ file_eject_callback (NautilusFile *file,
|
|||
nautilus_file_get_display_name (file));
|
||||
show_dialog (text,
|
||||
error->message,
|
||||
GTK_WINDOW (nautilus_files_view_get_window (view)),
|
||||
GTK_WINDOW (nautilus_files_view_get_window (self)),
|
||||
GTK_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -6908,9 +6900,7 @@ file_stop_callback (NautilusFile *file,
|
|||
GError *error,
|
||||
gpointer callback_data)
|
||||
{
|
||||
NautilusFilesView *view;
|
||||
|
||||
view = NAUTILUS_FILES_VIEW (callback_data);
|
||||
g_autoptr (NautilusFilesView) self = NAUTILUS_FILES_VIEW (callback_data);
|
||||
|
||||
if (error != NULL &&
|
||||
(error->domain != G_IO_ERROR ||
|
||||
|
@ -6919,7 +6909,7 @@ file_stop_callback (NautilusFile *file,
|
|||
{
|
||||
show_dialog (_("Unable to stop drive"),
|
||||
error->message,
|
||||
GTK_WINDOW (nautilus_files_view_get_window (view)),
|
||||
GTK_WINDOW (nautilus_files_view_get_window (self)),
|
||||
GTK_MESSAGE_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -6947,7 +6937,7 @@ action_mount_volume (GSimpleAction *action,
|
|||
g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
|
||||
nautilus_file_mount (file, mount_op, NULL,
|
||||
file_mount_callback,
|
||||
view);
|
||||
g_object_ref (view));
|
||||
g_object_unref (mount_op);
|
||||
}
|
||||
}
|
||||
|
@ -7086,7 +7076,7 @@ action_stop_volume (GSimpleAction *action,
|
|||
GMountOperation *mount_op;
|
||||
mount_op = gtk_mount_operation_new (nautilus_files_view_get_containing_window (view));
|
||||
nautilus_file_stop (file, mount_op, NULL,
|
||||
file_stop_callback, view);
|
||||
file_stop_callback, g_object_ref (view));
|
||||
g_object_unref (mount_op);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user