[gedit] GeditDocument: save gvfs metadata synchronously
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] GeditDocument: save gvfs metadata synchronously
- Date: Sun, 14 Dec 2014 14:28:57 +0000 (UTC)
commit 2d1e253aa577b9b5b2e0acc2ddc240b0b10e3996
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Dec 14 15:14:39 2014 +0100
GeditDocument: save gvfs metadata synchronously
The metadata loading is synchronous too.
https://bugzilla.gnome.org/show_bug.cgi?id=736591
gedit/gedit-document.c | 41 +++++++++++++++++++----------------------
1 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index 4b2e343..c9c139b 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -1619,21 +1619,6 @@ gedit_document_get_metadata (GeditDocument *doc,
return NULL;
}
-static void
-set_attributes_cb (GFile *location,
- GAsyncResult *result)
-{
- GError *error = NULL;
-
- g_file_set_attributes_finish (location, result, NULL, &error);
-
- if (error != NULL)
- {
- g_warning ("Set document metadata failed: %s", error->message);
- g_error_free (error);
- }
-}
-
/**
* gedit_document_set_metadata:
* @doc: a #GeditDocument
@@ -1687,13 +1672,25 @@ gedit_document_set_metadata (GeditDocument *doc,
if (location != NULL)
{
- g_file_set_attributes_async (location,
- info,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- NULL,
- (GAsyncReadyCallback) set_attributes_cb,
- NULL);
+ GError *error = NULL;
+
+ /* We save synchronously since metadata is always local so it
+ * should be fast. Moreover this function can be called on
+ * application shutdown, when the main loop has already exited,
+ * so an async operation would not terminate.
+ * https://bugzilla.gnome.org/show_bug.cgi?id=736591
+ */
+ g_file_set_attributes_from_info (location,
+ info,
+ G_FILE_QUERY_INFO_NONE,
+ NULL,
+ &error);
+
+ if (error != NULL)
+ {
+ g_warning ("Set document metadata failed: %s", error->message);
+ g_error_free (error);
+ }
}
g_object_unref (info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]