[gnome-software] Use autoptr in a few more places
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use autoptr in a few more places
- Date: Sun, 13 Sep 2015 12:07:49 +0000 (UTC)
commit 0216c2a4e32bfc4ba3d2d9a1f4dd3e31f0f57d9e
Author: Kalev Lember <klember redhat com>
Date: Sun Sep 13 13:35:36 2015 +0200
Use autoptr in a few more places
src/gs-plugin-loader.c | 12 ++++--------
src/gs-self-test.c | 4 +---
src/gs-shell-category.c | 8 ++------
src/gs-shell-installed.c | 3 +--
src/gs-shell-overview.c | 12 ++++--------
src/gs-shell-search-provider.c | 4 ++--
src/gs-shell-search.c | 3 +--
src/gs-shell-updates.c | 3 +--
src/gs-sources-dialog.c | 7 ++-----
9 files changed, 18 insertions(+), 38 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index f494f5a..5e910d9 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -255,15 +255,15 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
{
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
GList *l;
- GList *addons_list = NULL;
- GList *related_list = NULL;
GPtrArray *addons;
GPtrArray *related;
GsApp *app;
GsPlugin *plugin;
gboolean ret = TRUE;
guint i;
- GList *freeze_list;
+ g_autoptr(GsAppList) addons_list = NULL;
+ g_autoptr(GsAppList) freeze_list = NULL;
+ g_autoptr(GsAppList) related_list = NULL;
/* freeze all apps */
freeze_list = gs_plugin_list_copy (*list);
@@ -345,9 +345,6 @@ out:
for (l = freeze_list; l != NULL; l = l->next)
g_object_thaw_notify (G_OBJECT (l->data));
- gs_plugin_list_free (addons_list);
- gs_plugin_list_free (related_list);
- gs_plugin_list_free (freeze_list);
return ret;
}
@@ -3236,9 +3233,9 @@ gs_plugin_loader_set_network_status (GsPluginLoader *plugin_loader,
{
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
GList *l;
- GList *queue = NULL;
GsApp *app;
guint i;
+ g_autoptr(GsAppList) queue = NULL;
if (priv->online == online)
return;
@@ -3266,7 +3263,6 @@ gs_plugin_loader_set_network_status (GsPluginLoader *plugin_loader,
gs_plugin_loader_app_installed_cb,
g_object_ref (app));
}
- g_list_free_full (queue, g_object_unref);
}
/******************************************************************************/
diff --git a/src/gs-self-test.c b/src/gs-self-test.c
index 31507f7..1c56dda 100644
--- a/src/gs-self-test.c
+++ b/src/gs-self-test.c
@@ -542,11 +542,11 @@ gs_plugin_loader_empty_func (void)
GList *apps;
GList *l;
GList *l2;
- GList *list;
GList *subcats;
GsCategory *category;
GsCategory *sub;
guint empty_subcats_cnt = 0;
+ g_autoptr(GsAppList) list = NULL;
g_autoptr(GsPluginLoader) loader = NULL;
/* not avaiable in make distcheck */
@@ -620,8 +620,6 @@ gs_plugin_loader_empty_func (void)
g_list_free (subcats);
}
g_assert_cmpint (empty_subcats_cnt, ==, 0);
-
- gs_plugin_list_free (list);
}
static void
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index e013b00..7595208 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -87,12 +87,12 @@ gs_shell_category_get_apps_cb (GObject *source_object,
{
gint i = 0;
GList *l;
- GList *list;
GsApp *app;
GtkWidget *tile;
GsShellCategory *self = GS_SHELL_CATEGORY (user_data);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
list = gs_plugin_loader_get_category_apps_finish (plugin_loader,
res,
@@ -100,7 +100,7 @@ gs_shell_category_get_apps_cb (GObject *source_object,
if (list == NULL) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning ("failed to get apps for category apps: %s", error->message);
- goto out;
+ return;
}
gtk_grid_remove_column (GTK_GRID (self->category_detail_grid), 1);
gtk_grid_remove_column (GTK_GRID (self->category_detail_grid), 0);
@@ -115,10 +115,6 @@ gs_shell_category_get_apps_cb (GObject *source_object,
if (i == 1)
gtk_grid_attach (GTK_GRID (self->category_detail_grid), self->col1_placeholder, 1, 0, 1, 1);
-
-out:
- gs_plugin_list_free (list);
-
}
static void
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 9fbdfc6..f4a1f96 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -188,11 +188,11 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
gpointer user_data)
{
GList *l;
- GList *list;
GsApp *app;
GsShellInstalled *self = GS_SHELL_INSTALLED (user_data);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
gs_stop_spinner (GTK_SPINNER (self->spinner_install));
gtk_stack_set_visible_child_name (GTK_STACK (self->stack_install), "view");
@@ -213,7 +213,6 @@ gs_shell_installed_get_installed_cb (GObject *source_object,
gs_shell_installed_add_app (self, app);
}
out:
- gs_plugin_list_free (list);
gs_shell_installed_pending_apps_changed_cb (plugin_loader, self);
}
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index e43ce7b..9bfa665 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -128,11 +128,11 @@ gs_shell_overview_get_popular_cb (GObject *source_object,
GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
GList *l;
- GList *list;
GsApp *app;
gint i;
GtkWidget *tile;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
/* get popular apps */
list = gs_plugin_loader_get_popular_finish (plugin_loader, res, &error);
@@ -160,7 +160,6 @@ gs_shell_overview_get_popular_cb (GObject *source_object,
priv->empty = FALSE;
out:
- gs_plugin_list_free (list);
priv->loading_popular = FALSE;
priv->refresh_count--;
if (priv->refresh_count == 0) {
@@ -179,11 +178,11 @@ gs_shell_overview_get_popular_rotating_cb (GObject *source_object,
GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
GList *l;
- GList *list;
GsApp *app;
gint i;
GtkWidget *tile;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
/* get popular apps */
list = gs_plugin_loader_get_category_apps_finish (plugin_loader, res, &error);
@@ -217,7 +216,6 @@ gs_shell_overview_get_popular_rotating_cb (GObject *source_object,
priv->empty = FALSE;
out:
- gs_plugin_list_free (list);
load_data_free (load_data);
priv->loading_popular_rotating = FALSE;
priv->refresh_count--;
@@ -247,9 +245,9 @@ gs_shell_overview_get_featured_cb (GObject *source_object,
GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
GtkWidget *tile;
- GList *list;
GsApp *app;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
list = gs_plugin_loader_get_featured_finish (plugin_loader, res, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -279,7 +277,6 @@ gs_shell_overview_get_featured_cb (GObject *source_object,
priv->empty = FALSE;
out:
- gs_plugin_list_free (list);
priv->loading_featured = FALSE;
priv->refresh_count--;
if (priv->refresh_count == 0) {
@@ -312,11 +309,11 @@ gs_shell_overview_get_categories_cb (GObject *source_object,
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
gint i;
GList *l;
- GList *list;
GsCategory *cat;
GtkWidget *tile;
gboolean has_category = FALSE;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
list = gs_plugin_loader_get_categories_finish (plugin_loader, res, &error);
if (list == NULL) {
@@ -338,7 +335,6 @@ gs_shell_overview_get_categories_cb (GObject *source_object,
has_category = TRUE;
}
out:
- gs_plugin_list_free (list);
if (has_category) {
priv->empty = FALSE;
}
diff --git a/src/gs-shell-search-provider.c b/src/gs-shell-search-provider.c
index e7e546f..b86d5e7 100644
--- a/src/gs-shell-search-provider.c
+++ b/src/gs-shell-search-provider.c
@@ -79,8 +79,9 @@ search_done_cb (GObject *source,
{
PendingSearch *search = user_data;
GsShellSearchProvider *self = search->provider;
- GList *list, *l;
+ GList *l;
GVariantBuilder builder;
+ g_autoptr(GsAppList) list = NULL;
list = gs_plugin_loader_search_finish (self->plugin_loader, res, NULL);
if (list == NULL) {
@@ -102,7 +103,6 @@ search_done_cb (GObject *source,
}
g_dbus_method_invocation_return_value (search->invocation, g_variant_new ("(as)", &builder));
- g_list_free_full (list, g_object_unref);
pending_search_free (search);
g_application_release (g_application_get_default ());
}
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index 09468be..f84793a 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -93,12 +93,12 @@ gs_shell_search_get_search_cb (GObject *source_object,
gpointer user_data)
{
GList *l;
- GList *list;
GsApp *app;
GsShellSearch *self = GS_SHELL_SEARCH (user_data);
GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
GtkWidget *app_row;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
list = gs_plugin_loader_search_finish (plugin_loader, res, &error);
if (list == NULL) {
@@ -138,7 +138,6 @@ gs_shell_search_get_search_cb (GObject *source_object,
gs_shell_show_details (self->shell, self->appid_to_show);
g_clear_pointer (&self->appid_to_show, g_free);
}
- g_list_free_full (list, g_object_unref);
}
/**
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index c39e235..781a3be 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -443,9 +443,9 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
GsShellUpdates *self)
{
GList *l;
- GList *list;
GtkWidget *widget;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
self->cache_valid = TRUE;
@@ -492,7 +492,6 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
GS_SHELL_UPDATES_STATE_HAS_UPDATES);
}
- gs_plugin_list_free (list);
self->in_progress = FALSE;
}
diff --git a/src/gs-sources-dialog.c b/src/gs-sources-dialog.c
index 485a189..8bbd9f6 100644
--- a/src/gs-sources-dialog.c
+++ b/src/gs-sources-dialog.c
@@ -147,9 +147,9 @@ get_sources_cb (GsPluginLoader *plugin_loader,
GsSourcesDialog *dialog)
{
GList *l;
- GList *list;
GsApp *app;
g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
/* show results */
gs_stop_spinner (GTK_SPINNER (dialog->spinner));
@@ -171,7 +171,7 @@ get_sources_cb (GsPluginLoader *plugin_loader,
gtk_stack_set_visible_child_name (GTK_STACK (dialog->stack), "empty");
gtk_style_context_add_class (gtk_widget_get_style_context (dialog->label_header),
"dim-label");
- goto out;
+ return;
}
gtk_style_context_remove_class (gtk_widget_get_style_context (dialog->label_header),
@@ -183,9 +183,6 @@ get_sources_cb (GsPluginLoader *plugin_loader,
app = GS_APP (l->data);
add_source (GTK_LIST_BOX (dialog->listbox), app);
}
-out:
- if (list != NULL)
- gs_plugin_list_free (list);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]