[gnome-software] hardcoded-featured: Return an error if the required data is not present



commit 04c711604f9bee8ecadc03ba325fd57c801b437f
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jan 23 16:42:26 2014 +0000

    hardcoded-featured: Return an error if the required data is not present

 src/plugins/gs-plugin-hardcoded-featured.c |   38 +++++++++++++++++----------
 1 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/src/plugins/gs-plugin-hardcoded-featured.c b/src/plugins/gs-plugin-hardcoded-featured.c
index dad80bc..8c82210 100644
--- a/src/plugins/gs-plugin-hardcoded-featured.c
+++ b/src/plugins/gs-plugin-hardcoded-featured.c
@@ -52,7 +52,7 @@ gs_plugin_add_featured (GsPlugin *plugin,
 {
        GDateTime *date;
        GKeyFile *kf;
-       GsApp *app;
+       GsApp *app = NULL;
        const gchar *group = NULL;
        gboolean ret = TRUE;
        gchar **apps = NULL;
@@ -92,24 +92,34 @@ gs_plugin_add_featured (GsPlugin *plugin,
        }
 
        app = gs_app_new (group);
-       s = g_key_file_get_string (kf, group, "background", NULL);
-       if (s != NULL) {
-               gs_app_set_metadata (app, "Featured::background", s);
-               g_free (s);
+       s = g_key_file_get_string (kf, group, "background", error);
+       if (s == NULL) {
+               ret = FALSE;
+               goto out;
        }
-       s = g_key_file_get_string (kf, group, "stroke", NULL);
-       if (s != NULL) {
-               gs_app_set_metadata (app, "Featured::stroke-color", s);
-               g_free (s);
+       gs_app_set_metadata (app, "Featured::background", s);
+       g_free (s);
+
+       s = g_key_file_get_string (kf, group, "stroke", error);
+       if (s == NULL) {
+               ret = FALSE;
+               goto out;
        }
-       s = g_key_file_get_string (kf, group, "text", NULL);
-       if (s != NULL) {
-               gs_app_set_metadata (app, "Featured::text-color", s);
-               g_free (s);
+       gs_app_set_metadata (app, "Featured::stroke-color", s);
+       g_free (s);
+
+       s = g_key_file_get_string (kf, group, "text", error);
+       if (s == NULL) {
+               ret = FALSE;
+               goto out;
        }
+       gs_app_set_metadata (app, "Featured::text-color", s);
+       g_free (s);
+
        gs_plugin_add_app (list, app);
-       g_object_unref (app);
 out:
+       if (app != NULL)
+               g_object_unref (app);
        if (kf != NULL)
                g_key_file_unref (kf);
        g_free (path);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]