[gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 120/331] Use g_autoptr for Json code
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased-corrected: 120/331] Use g_autoptr for Json code
- Date: Wed, 4 May 2016 14:08:36 +0000 (UTC)
commit 67ce94c81a3898bd167f1fc2c1c2bca51364c5b5
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Mar 1 22:02:24 2016 +1300
Use g_autoptr for Json code
src/plugins/gs-plugin-snappy.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snappy.c b/src/plugins/gs-plugin-snappy.c
index bdfb05d..ac63534 100644
--- a/src/plugins/gs-plugin-snappy.c
+++ b/src/plugins/gs-plugin-snappy.c
@@ -29,6 +29,11 @@
#include <libsoup/soup.h>
#include <json-glib/json-glib.h>
+// This is fixed in json-glib 1.1.1
+#ifndef JsonParser_autoptr
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(JsonParser, g_object_unref)
+#endif
+
// snapd API documentation is at https://github.com/ubuntu-core/snappy/blob/master/docs/rest.md
struct GsPluginPrivate {
@@ -55,7 +60,7 @@ static GSocket *
open_snapd_socket (GError **error)
{
GSocket *socket;
- g_autoptr (GSocketAddress) address = NULL;
+ g_autoptr(GSocketAddress) address = NULL;
g_autoptr(GError) sub_error = NULL;
socket = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT,
&sub_error);
@@ -226,7 +231,7 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
GPtrArray *query_fields;
g_autoptr (GString) path = NULL;
g_autofree gchar *reason_phrase = NULL, *response_type = NULL, *response = NULL;
- JsonParser *parser;
+ g_autoptr(JsonParser) parser = NULL;
JsonObject *root, *result, *packages;
GList *package_list, *link;
g_autoptr(GError) sub_error = NULL;
@@ -376,7 +381,6 @@ get_apps (GsPlugin *plugin, const gchar *sources, gchar **search_terms, GList **
}
gs_plugin_add_app (list, app);
}
- g_object_unref (parser);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]