[gnome-builder] flatpak: handle application addin not yet loaded



commit 556c51b91dce6817fcaeb027e0f2e42068abb48e
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 8 23:38:28 2017 -0700

    flatpak: handle application addin not yet loaded
    
    If our application addin has not yet loaded, we can't get access to
    runtimes yet.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781960

 plugins/flatpak/gbp-flatpak-preferences-addin.c |   24 ++++++++++++++++------
 1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-preferences-addin.c b/plugins/flatpak/gbp-flatpak-preferences-addin.c
index ef32e3f..b3a77c8 100644
--- a/plugins/flatpak/gbp-flatpak-preferences-addin.c
+++ b/plugins/flatpak/gbp-flatpak-preferences-addin.c
@@ -215,7 +215,6 @@ gbp_flatpak_preferences_addin_reload_worker (GTask        *task,
                                              GCancellable *cancellable)
 {
   GbpFlatpakPreferencesAddin *self = (GbpFlatpakPreferencesAddin *)source_object;
-  g_autoptr(GPtrArray) installations = NULL;
   g_autoptr(GPtrArray) runtimes = NULL;
   GbpFlatpakApplicationAddin *app_addin;
 
@@ -227,14 +226,25 @@ gbp_flatpak_preferences_addin_reload_worker (GTask        *task,
   runtimes = g_ptr_array_new_with_free_func (g_object_unref);
 
   app_addin = gbp_flatpak_application_addin_get_default ();
-  installations = gbp_flatpak_application_addin_get_installations (app_addin);
-  for (guint i = 0; i < installations->len; i++)
+
+  /*
+   * If our application addin has not yet been loaded, we won't have any
+   * runtimes loaded yet.
+   */
+  if (app_addin != NULL)
     {
-      FlatpakInstallation *installation = g_ptr_array_index (installations, i);
-      populate_runtimes (self, installation, runtimes);
-    }
+      g_autoptr(GPtrArray) installations = NULL;
 
-  g_ptr_array_sort (runtimes, compare_refs);
+      installations = gbp_flatpak_application_addin_get_installations (app_addin);
+
+      for (guint i = 0; i < installations->len; i++)
+        {
+          FlatpakInstallation *installation = g_ptr_array_index (installations, i);
+          populate_runtimes (self, installation, runtimes);
+        }
+
+      g_ptr_array_sort (runtimes, compare_refs);
+    }
 
   g_task_return_pointer (task, g_steal_pointer (&runtimes), (GDestroyNotify)g_ptr_array_unref);
 


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