[gvfs/gnome-3-10] gvfsjobunmount: don't unmount if dialog was cancelled
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gnome-3-10] gvfsjobunmount: don't unmount if dialog was cancelled
- Date: Wed, 3 Dec 2014 09:23:03 +0000 (UTC)
commit 6344510ccebfbc73dd9ecf9106aa8234959156c7
Author: Ondrej Holy <oholy redhat com>
Date: Thu Sep 11 08:55:21 2014 +0200
gvfsjobunmount: don't unmount if dialog was cancelled
If the dialog about blocking processes was cancelled,
G_IO_ERROR_FAILED_HANDLED will be returned and backend
won't be unmounted.
https://bugzilla.gnome.org/show_bug.cgi?id=710986
daemon/gvfsbackend.c | 25 ++++++++++++++++++-------
daemon/gvfsbackend.h | 3 ++-
daemon/gvfsjobunmount.c | 14 ++++++++++----
3 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index af45d1c..6f05f51 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -810,22 +810,29 @@ complete_unmount_with_op (UnmountWithOpData *data)
ret = TRUE;
+ simple = g_simple_async_result_new (G_OBJECT (data->backend),
+ data->callback,
+ data->user_data,
+ NULL);
+
if (data->no_more_processes)
{
/* do nothing, e.g. return TRUE to signal we should unmount */
}
+ else if (!data->ret)
+ {
+ /* "show-processes" signal wasn't handled, return TRUE to signal we should unmount */
+ }
else
{
if (data->aborted || data->choice == 1)
{
+ g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED,
+ "GMountOperation aborted");
ret = FALSE;
}
}
- simple = g_simple_async_result_new (G_OBJECT (data->backend),
- data->callback,
- data->user_data,
- NULL);
g_simple_async_result_set_op_res_gboolean (simple, ret);
g_simple_async_result_complete (simple);
g_object_unref (simple);
@@ -893,22 +900,26 @@ unmount_with_op_data_free (UnmountWithOpData *data)
* @backend: A #GVfsBackend.
* @res: A #GAsyncResult obtained from the @callback function passed
* to g_vfs_backend_unmount_with_operation().
+ * @error: A #GError, or NULL.
*
* Gets the result of the operation started by
* gvfs_backend_unmount_with_operation_sync().
*
+ * If the operation was cancelled, G_IO_ERROR_FAILED_HANDLED will be returned.
+ *
* Returns: %TRUE if the backend should be unmounted (either no blocking
* processes or the user decided to unmount anyway), %FALSE if
- * no action should be taken.
+ * no action should be taken (error is set).
*/
gboolean
g_vfs_backend_unmount_with_operation_finish (GVfsBackend *backend,
- GAsyncResult *res)
+ GAsyncResult *res,
+ GError **error)
{
gboolean ret;
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
- if (g_simple_async_result_propagate_error (simple, NULL))
+ if (g_simple_async_result_propagate_error (simple, error))
{
ret = FALSE;
}
diff --git a/daemon/gvfsbackend.h b/daemon/gvfsbackend.h
index 45ec4fb..16836c8 100644
--- a/daemon/gvfsbackend.h
+++ b/daemon/gvfsbackend.h
@@ -508,7 +508,8 @@ gboolean g_vfs_backend_get_block_requests (GVfsBackend
gboolean g_vfs_backend_has_blocking_processes (GVfsBackend *backend);
gboolean g_vfs_backend_unmount_with_operation_finish (GVfsBackend *backend,
- GAsyncResult *res);
+ GAsyncResult *res,
+ GError **error);
void g_vfs_backend_unmount_with_operation (GVfsBackend *backend,
GMountSource *mount_source,
diff --git a/daemon/gvfsjobunmount.c b/daemon/gvfsjobunmount.c
index d97f846..14c8e3c 100644
--- a/daemon/gvfsjobunmount.c
+++ b/daemon/gvfsjobunmount.c
@@ -210,13 +210,19 @@ unmount_cb (GVfsBackend *backend,
GVfsBackendClass *class = G_VFS_BACKEND_GET_CLASS (op_job->backend);
gboolean should_unmount;
gboolean finished;
+ GError *error = NULL;
should_unmount = g_vfs_backend_unmount_with_operation_finish (backend,
- res);
-
- if (should_unmount)
- op_job->flags |= G_MOUNT_UNMOUNT_FORCE;
+ res,
+ &error);
+ if (!should_unmount)
+ {
+ g_vfs_job_failed_from_error (G_VFS_JOB (op_job), error);
+ g_error_free (error);
+ return;
+ }
+ op_job->flags |= G_MOUNT_UNMOUNT_FORCE;
finished = job_finish_immediately_if_possible (op_job);
if (! finished)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]