[gnome-builder] beautifier: use gbytes for async calls
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] beautifier: use gbytes for async calls
- Date: Thu, 1 Feb 2018 03:50:50 +0000 (UTC)
commit f4d5e02dcac2dfe220f81df89a754d93eeafcf2a
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 31 19:49:08 2018 -0800
beautifier: use gbytes for async calls
Rather than relying on dependent API to do this.
src/plugins/beautifier/gb-beautifier-helper.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/beautifier/gb-beautifier-helper.c b/src/plugins/beautifier/gb-beautifier-helper.c
index 8558b63dc..8064e939a 100644
--- a/src/plugins/beautifier/gb-beautifier-helper.c
+++ b/src/plugins/beautifier/gb-beautifier-helper.c
@@ -71,6 +71,8 @@ gb_beautifier_helper_remove_temp_for_file (GbBeautifierEditorAddin *self,
{
g_autofree gchar *path = NULL;
+ g_assert (GB_IS_BEAUTIFIER_EDITOR_ADDIN (self));
+ g_assert (file != NULL);
g_assert (G_IS_FILE (file));
path = g_file_get_path (file);
@@ -172,6 +174,7 @@ gb_beautifier_helper_create_tmp_file_async (GbBeautifierEditorAddin *self,
{
g_autoptr(GTask) task = NULL;
g_autoptr(GFile) file = NULL;
+ g_autoptr(GBytes) bytes = NULL;
g_autofree gchar *tmp_path = NULL;
gint fd;
@@ -196,15 +199,16 @@ gb_beautifier_helper_create_tmp_file_async (GbBeautifierEditorAddin *self,
g_close (fd, NULL);
file = g_file_new_for_path (tmp_path);
- g_file_replace_contents_async (file,
- text,
- strlen (text),
- NULL,
- FALSE,
- G_FILE_CREATE_REPLACE_DESTINATION,
- NULL,
- gb_beautifier_helper_create_tmp_file_cb,
- g_steal_pointer (&task));
+ bytes = g_bytes_new (text, strlen (text));
+
+ g_file_replace_contents_bytes_async (file,
+ bytes,
+ NULL,
+ FALSE,
+ G_FILE_CREATE_REPLACE_DESTINATION,
+ NULL,
+ gb_beautifier_helper_create_tmp_file_cb,
+ g_steal_pointer (&task));
}
GFile *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]