[gnome-builder] flatpak: handle NULL installation gracefully



commit 14dd7f829d9b005cd786f4e356f283873cb840a4
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jun 25 18:52:06 2017 -0700

    flatpak: handle NULL installation gracefully
    
    This can happen at start-up. We can just return an empty array
    since the reload signal will cause things to reset.

 plugins/flatpak/gbp-flatpak-application-addin.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-application-addin.c b/plugins/flatpak/gbp-flatpak-application-addin.c
index eeb8be8..d044c63 100644
--- a/plugins/flatpak/gbp-flatpak-application-addin.c
+++ b/plugins/flatpak/gbp-flatpak-application-addin.c
@@ -379,14 +379,18 @@ gbp_flatpak_application_addin_get_installations (GbpFlatpakApplicationAddin *sel
 
   ret = g_ptr_array_new_with_free_func (g_object_unref);
 
-  for (guint i = 0; i < self->installations->len; i++)
+  /* Might be NULL before things have loaded at startup */
+  if (self->installations != NULL)
     {
-      InstallInfo *info = g_ptr_array_index (self->installations, i);
+      for (guint i = 0; i < self->installations->len; i++)
+        {
+          InstallInfo *info = g_ptr_array_index (self->installations, i);
 
-      g_assert (info != NULL);
-      g_assert (FLATPAK_IS_INSTALLATION (info->installation));
+          g_assert (info != NULL);
+          g_assert (FLATPAK_IS_INSTALLATION (info->installation));
 
-      g_ptr_array_add (ret, g_object_ref (info->installation));
+          g_ptr_array_add (ret, g_object_ref (info->installation));
+        }
     }
 
   IDE_RETURN (ret);


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