[gnome-software/gnome-3-26] trivial: Fix a critical warning if XDG_CURRENT_DESKTOP is unset



commit 279bc6baf9a323ca9918270be7b4d5b1bbfb3fc5
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 18 19:46:22 2017 +0100

    trivial: Fix a critical warning if XDG_CURRENT_DESKTOP is unset

 plugins/core/gs-appstream.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index b3b5087..cf72c96 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -697,20 +697,22 @@ gs_appstream_refine_app (GsPlugin *plugin,
         */
        array = as_app_get_compulsory_for_desktops (item);
        current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
-       xdg_current_desktops = g_strsplit (current_desktop, ":", 0);
-       for (i = 0; i < array->len; i++) {
-               tmp = g_ptr_array_index (array, i);
-               /* if the value has a :, check the whole string */
-               if (g_strstr_len (tmp, -1, ":")) {
-                       if (g_strcmp0 (current_desktop, tmp) == 0) {
+       if (current_desktop != NULL) {
+               xdg_current_desktops = g_strsplit (current_desktop, ":", 0);
+               for (i = 0; i < array->len; i++) {
+                       tmp = g_ptr_array_index (array, i);
+                       /* if the value has a :, check the whole string */
+                       if (g_strstr_len (tmp, -1, ":")) {
+                               if (g_strcmp0 (current_desktop, tmp) == 0) {
+                                       gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
+                                       break;
+                               }
+                       /* otherwise check if any element matches this one */
+                       } else if (g_strv_contains ((const gchar * const *) xdg_current_desktops,
+                                  tmp)) {
                                gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
                                break;
                        }
-               /* otherwise check if any element matches this one */
-               } else if (g_strv_contains ((const gchar * const *) xdg_current_desktops,
-                          tmp)) {
-                       gs_app_add_quirk (app, AS_APP_QUIRK_COMPULSORY);
-                       break;
                }
        }
 


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