[gnome-software] Drop references in dispose, not finalize
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Drop references in dispose, not finalize
- Date: Sun, 7 Jun 2015 16:00:19 +0000 (UTC)
commit ffb1df09b684806b410cfaac6f6bbf697a920bb4
Author: Kalev Lember <kalevlember gmail com>
Date: Sun Jun 7 15:04:25 2015 +0200
Drop references in dispose, not finalize
This makes it possible to break reference cycles during object
destruction.
src/gs-app.c | 33 +++++++++++++++++++++++----------
src/gs-application.c | 6 +++---
src/gs-category.c | 16 +++++++++++++++-
src/gs-folders.c | 12 +++++++++++-
src/gs-history-dialog.c | 12 ++++++------
src/gs-plugin-loader.c | 38 +++++++++++++++++++++++++++-----------
src/gs-proxy-settings.c | 12 +++++++-----
src/gs-shell-category.c | 6 +++---
src/gs-shell-details.c | 20 +++++++++-----------
src/gs-shell-extras.c | 25 +++++++++++++------------
src/gs-shell-installed.c | 18 +++++++++---------
src/gs-shell-overview.c | 12 ++++++------
src/gs-shell-search.c | 22 ++++++++++------------
src/gs-shell-updates.c | 22 +++++++++++-----------
src/gs-shell.c | 19 +++++++++++--------
src/gs-update-dialog.c | 6 +++---
src/gs-update-list.c | 6 +++---
src/gs-update-monitor.c | 12 +++++++++++-
18 files changed, 181 insertions(+), 116 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 52db1a2..8dd41a5 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -2088,6 +2088,28 @@ gs_app_set_property (GObject *object, guint prop_id, const GValue *value, GParam
}
/**
+ * gs_app_dispose:
+ * @object: The object to dispose
+ **/
+static void
+gs_app_dispose (GObject *object)
+{
+ GsApp *app = GS_APP (object);
+ GsAppPrivate *priv = APP_PRIV (app);
+
+ g_clear_object (&priv->featured_pixbuf);
+ g_clear_object (&priv->icon);
+ g_clear_object (&priv->pixbuf);
+
+ g_clear_pointer (&priv->addons, g_ptr_array_unref);
+ g_clear_pointer (&priv->history, g_ptr_array_unref);
+ g_clear_pointer (&priv->related, g_ptr_array_unref);
+ g_clear_pointer (&priv->screenshots, g_ptr_array_unref);
+
+ G_OBJECT_CLASS (gs_app_parent_class)->dispose (object);
+}
+
+/**
* gs_app_finalize:
* @object: The object to finalize
**/
@@ -2111,23 +2133,13 @@ gs_app_finalize (GObject *object)
g_free (priv->summary);
g_free (priv->summary_missing);
g_free (priv->description);
- g_ptr_array_unref (priv->screenshots);
g_free (priv->update_version);
g_free (priv->update_version_ui);
g_free (priv->update_details);
g_free (priv->management_plugin);
g_hash_table_unref (priv->metadata);
g_hash_table_unref (priv->addons_hash);
- g_ptr_array_unref (priv->addons);
g_hash_table_unref (priv->related_hash);
- g_ptr_array_unref (priv->related);
- g_ptr_array_unref (priv->history);
- if (priv->icon != NULL)
- g_object_unref (priv->icon);
- if (priv->pixbuf != NULL)
- g_object_unref (priv->pixbuf);
- if (priv->featured_pixbuf != NULL)
- g_object_unref (priv->featured_pixbuf);
g_ptr_array_unref (priv->categories);
if (priv->keywords != NULL)
g_ptr_array_unref (priv->keywords);
@@ -2144,6 +2156,7 @@ gs_app_class_init (GsAppClass *klass)
{
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gs_app_dispose;
object_class->finalize = gs_app_finalize;
object_class->get_property = gs_app_get_property;
object_class->set_property = gs_app_set_property;
diff --git a/src/gs-application.c b/src/gs-application.c
index 51fd8d5..2dc2ba0 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -526,7 +526,7 @@ gs_application_activate (GApplication *application)
}
static void
-gs_application_finalize (GObject *object)
+gs_application_dispose (GObject *object)
{
GsApplication *app = GS_APPLICATION (object);
@@ -546,7 +546,7 @@ gs_application_finalize (GObject *object)
g_clear_object (&app->dbus_helper);
g_clear_object (&app->settings);
- G_OBJECT_CLASS (gs_application_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_application_parent_class)->dispose (object);
}
static gboolean
@@ -661,7 +661,7 @@ out:
static void
gs_application_class_init (GsApplicationClass *class)
{
- G_OBJECT_CLASS (class)->finalize = gs_application_finalize;
+ G_OBJECT_CLASS (class)->dispose = gs_application_dispose;
G_APPLICATION_CLASS (class)->startup = gs_application_startup;
G_APPLICATION_CLASS (class)->activate = gs_application_activate;
G_APPLICATION_CLASS (class)->local_command_line = gs_application_local_command_line;
diff --git a/src/gs-category.c b/src/gs-category.c
index cdc6d9a..68e882c 100644
--- a/src/gs-category.c
+++ b/src/gs-category.c
@@ -178,6 +178,20 @@ gs_category_sort_subcategories (GsCategory *category)
}
static void
+gs_category_dispose (GObject *object)
+{
+ GsCategory *category = GS_CATEGORY (object);
+ GsCategoryPrivate *priv = category->priv;
+
+ if (priv->subcategories != NULL) {
+ g_list_free_full (priv->subcategories, g_object_unref);
+ priv->subcategories = NULL;
+ }
+
+ G_OBJECT_CLASS (gs_category_parent_class)->dispose (object);
+}
+
+static void
gs_category_finalize (GObject *object)
{
GsCategory *category = GS_CATEGORY (object);
@@ -188,7 +202,6 @@ gs_category_finalize (GObject *object)
(gpointer *) &priv->parent);
g_free (priv->id);
g_free (priv->name);
- g_list_free_full (priv->subcategories, g_object_unref);
G_OBJECT_CLASS (gs_category_parent_class)->finalize (object);
}
@@ -197,6 +210,7 @@ static void
gs_category_class_init (GsCategoryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gs_category_dispose;
object_class->finalize = gs_category_finalize;
}
diff --git a/src/gs-folders.c b/src/gs-folders.c
index fa8edae..6cd47b2 100644
--- a/src/gs-folders.c
+++ b/src/gs-folders.c
@@ -275,12 +275,21 @@ clear (GsFolders *folders)
}
static void
+gs_folders_dispose (GObject *object)
+{
+ GsFolders *folders = GS_FOLDERS (object);
+
+ g_clear_object (&folders->priv->settings);
+
+ G_OBJECT_CLASS (gs_folders_parent_class)->dispose (object);
+}
+
+static void
gs_folders_finalize (GObject *object)
{
GsFolders *folders = GS_FOLDERS (object);
clear (folders);
- g_object_unref (folders->priv->settings);
G_OBJECT_CLASS (gs_folders_parent_class)->finalize (object);
}
@@ -289,6 +298,7 @@ static void
gs_folders_class_init (GsFoldersClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gs_folders_dispose;
object_class->finalize = gs_folders_finalize;
}
diff --git a/src/gs-history-dialog.c b/src/gs-history-dialog.c
index b8fe46e..f2a0e20 100644
--- a/src/gs-history-dialog.c
+++ b/src/gs-history-dialog.c
@@ -185,16 +185,16 @@ scrollbar_mapped_cb (GtkWidget *sb, GtkScrolledWindow *swin)
}
static void
-gs_history_dialog_finalize (GObject *object)
+gs_history_dialog_dispose (GObject *object)
{
GsHistoryDialog *dialog = GS_HISTORY_DIALOG (object);
GsHistoryDialogPrivate *priv = gs_history_dialog_get_instance_private (dialog);
- g_object_unref (priv->sizegroup_state);
- g_object_unref (priv->sizegroup_timestamp);
- g_object_unref (priv->sizegroup_version);
+ g_clear_object (&priv->sizegroup_state);
+ g_clear_object (&priv->sizegroup_timestamp);
+ g_clear_object (&priv->sizegroup_version);
- G_OBJECT_CLASS (gs_history_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_history_dialog_parent_class)->dispose (object);
}
static void
@@ -225,7 +225,7 @@ gs_history_dialog_class_init (GsHistoryDialogClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_history_dialog_finalize;
+ object_class->dispose = gs_history_dialog_dispose;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-history-dialog.ui");
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 559ce44..06eab22 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -3052,6 +3052,32 @@ gs_plugin_loader_plugin_free (GsPlugin *plugin)
}
/**
+ * gs_plugin_loader_dispose:
+ * @object: The object to dispose
+ **/
+static void
+gs_plugin_loader_dispose (GObject *object)
+{
+ GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (object);
+
+ if (plugin_loader->priv->updates_changed_id != 0) {
+ g_source_remove (plugin_loader->priv->updates_changed_id);
+ plugin_loader->priv->updates_changed_id = 0;
+ }
+ if (plugin_loader->priv->profile != NULL) {
+ gs_profile_stop (plugin_loader->priv->profile, "GsPluginLoader");
+ g_clear_object (&plugin_loader->priv->profile);
+ }
+
+ g_clear_object (&plugin_loader->priv->settings);
+ g_clear_pointer (&plugin_loader->priv->app_cache, g_hash_table_unref);
+ g_clear_pointer (&plugin_loader->priv->pending_apps, g_ptr_array_unref);
+ g_clear_pointer (&plugin_loader->priv->plugins, g_ptr_array_unref);
+
+ G_OBJECT_CLASS (gs_plugin_loader_parent_class)->dispose (object);
+}
+
+/**
* gs_plugin_loader_finalize:
* @object: The object to finalize
**/
@@ -3067,21 +3093,10 @@ gs_plugin_loader_finalize (GObject *object)
g_return_if_fail (plugin_loader->priv != NULL);
- if (plugin_loader->priv->updates_changed_id != 0)
- g_source_remove (plugin_loader->priv->updates_changed_id);
-
- /* application stop */
- gs_profile_stop (plugin_loader->priv->profile, "GsPluginLoader");
-
/* run the plugins */
gs_plugin_loader_run (plugin_loader, "gs_plugin_destroy");
- g_object_unref (plugin_loader->priv->settings);
- g_object_unref (plugin_loader->priv->profile);
g_strfreev (plugin_loader->priv->compatible_projects);
- g_hash_table_unref (plugin_loader->priv->app_cache);
- g_ptr_array_unref (plugin_loader->priv->pending_apps);
- g_ptr_array_unref (plugin_loader->priv->plugins);
g_free (plugin_loader->priv->location);
g_mutex_clear (&plugin_loader->priv->pending_apps_mutex);
@@ -3099,6 +3114,7 @@ gs_plugin_loader_class_init (GsPluginLoaderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gs_plugin_loader_dispose;
object_class->finalize = gs_plugin_loader_finalize;
signals [SIGNAL_STATUS_CHANGED] =
diff --git a/src/gs-proxy-settings.c b/src/gs-proxy-settings.c
index d5e5bec..aa16e76 100644
--- a/src/gs-proxy-settings.c
+++ b/src/gs-proxy-settings.c
@@ -161,26 +161,28 @@ gs_proxy_settings_init (GsProxySettings *proxy_settings)
}
static void
-gs_proxy_settings_finalize (GObject *object)
+gs_proxy_settings_dispose (GObject *object)
{
GsProxySettings *proxy_settings = GS_PROXY_SETTINGS (object);
- g_cancellable_cancel (proxy_settings->cancellable);
+ if (proxy_settings->cancellable != NULL) {
+ g_cancellable_cancel (proxy_settings->cancellable);
+ g_clear_object (&proxy_settings->cancellable);
+ }
- g_clear_object (&proxy_settings->cancellable);
g_clear_object (&proxy_settings->control);
g_clear_object (&proxy_settings->settings);
g_clear_object (&proxy_settings->settings_http);
g_clear_object (&proxy_settings->settings_ftp);
- G_OBJECT_CLASS (gs_proxy_settings_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_proxy_settings_parent_class)->dispose (object);
}
static void
gs_proxy_settings_class_init (GsProxySettingsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_proxy_settings_finalize;
+ object_class->dispose = gs_proxy_settings_dispose;
}
GsProxySettings *
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index dfa535a..464bbc1 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -280,7 +280,7 @@ gs_shell_category_init (GsShellCategory *shell)
}
static void
-gs_shell_category_finalize (GObject *object)
+gs_shell_category_dispose (GObject *object)
{
GsShellCategory *shell = GS_SHELL_CATEGORY (object);
GsShellCategoryPrivate *priv = shell->priv;
@@ -296,7 +296,7 @@ gs_shell_category_finalize (GObject *object)
g_clear_object (&priv->col0_placeholder);
g_clear_object (&priv->col1_placeholder);
- G_OBJECT_CLASS (gs_shell_category_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_category_parent_class)->dispose (object);
}
static void
@@ -305,7 +305,7 @@ gs_shell_category_class_init (GsShellCategoryClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_category_finalize;
+ object_class->dispose = gs_shell_category_dispose;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-shell-category.ui");
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 9b27fc0..de57cfd 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1245,23 +1245,21 @@ gs_shell_details_setup (GsShellDetails *shell_details,
}
/**
- * gs_shell_details_finalize:
+ * gs_shell_details_dispose:
**/
static void
-gs_shell_details_finalize (GObject *object)
+gs_shell_details_dispose (GObject *object)
{
GsShellDetails *shell_details = GS_SHELL_DETAILS (object);
GsShellDetailsPrivate *priv = shell_details->priv;
- g_object_unref (priv->builder);
- g_object_unref (priv->plugin_loader);
- g_object_unref (priv->cancellable);
- if (priv->app != NULL)
- g_object_unref (priv->app);
- if (priv->session != NULL)
- g_object_unref (priv->session);
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->plugin_loader);
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->app);
+ g_clear_object (&priv->session);
- G_OBJECT_CLASS (gs_shell_details_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_details_parent_class)->dispose (object);
}
/**
@@ -1274,7 +1272,7 @@ gs_shell_details_class_init (GsShellDetailsClass *klass)
GsPageClass *page_class = GS_PAGE_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_details_finalize;
+ object_class->dispose = gs_shell_details_dispose;
page_class->app_installed = gs_shell_details_app_installed;
page_class->app_removed = gs_shell_details_app_removed;
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index 7a283fe..3aab1ee 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -1173,26 +1173,27 @@ gs_shell_extras_setup (GsShellExtras *shell_extras,
}
static void
-gs_shell_extras_finalize (GObject *object)
+gs_shell_extras_dispose (GObject *object)
{
GsShellExtras *shell_extras = GS_SHELL_EXTRAS (object);
GsShellExtrasPrivate *priv = shell_extras->priv;
if (priv->search_cancellable != NULL) {
g_cancellable_cancel (priv->search_cancellable);
- g_object_unref (priv->search_cancellable);
+ g_clear_object (&priv->search_cancellable);
}
- g_object_unref (priv->sizegroup_image);
- g_object_unref (priv->sizegroup_name);
- g_object_unref (priv->language);
- g_object_unref (priv->vendor);
- g_object_unref (priv->builder);
- g_object_unref (priv->plugin_loader);
- g_object_unref (priv->cancellable);
- g_ptr_array_unref (priv->array_search_data);
+ g_clear_object (&priv->sizegroup_image);
+ g_clear_object (&priv->sizegroup_name);
+ g_clear_object (&priv->language);
+ g_clear_object (&priv->vendor);
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->plugin_loader);
+ g_clear_object (&priv->cancellable);
+
+ g_clear_pointer (&priv->array_search_data, g_ptr_array_unref);
- G_OBJECT_CLASS (gs_shell_extras_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_extras_parent_class)->dispose (object);
}
static void
@@ -1221,7 +1222,7 @@ gs_shell_extras_class_init (GsShellExtrasClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_extras_finalize;
+ object_class->dispose = gs_shell_extras_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-shell-extras.ui");
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index f38bf1f..e024830 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -761,22 +761,22 @@ gs_shell_installed_setup (GsShellInstalled *shell_installed,
}
/**
- * gs_shell_installed_finalize:
+ * gs_shell_installed_dispose:
**/
static void
-gs_shell_installed_finalize (GObject *object)
+gs_shell_installed_dispose (GObject *object)
{
GsShellInstalled *shell_installed = GS_SHELL_INSTALLED (object);
GsShellInstalledPrivate *priv = shell_installed->priv;
- g_object_unref (priv->sizegroup_image);
- g_object_unref (priv->sizegroup_name);
+ g_clear_object (&priv->sizegroup_image);
+ g_clear_object (&priv->sizegroup_name);
- g_object_unref (priv->builder);
- g_object_unref (priv->plugin_loader);
- g_object_unref (priv->cancellable);
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->plugin_loader);
+ g_clear_object (&priv->cancellable);
- G_OBJECT_CLASS (gs_shell_installed_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_installed_parent_class)->dispose (object);
}
/**
@@ -789,7 +789,7 @@ gs_shell_installed_class_init (GsShellInstalledClass *klass)
GsPageClass *page_class = GS_PAGE_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_installed_finalize;
+ object_class->dispose = gs_shell_installed_dispose;
page_class->app_removed = gs_shell_installed_app_removed;
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-shell-installed.ui");
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index d106a8f..bf1b82f 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -534,17 +534,17 @@ gs_shell_overview_init (GsShellOverview *shell)
}
static void
-gs_shell_overview_finalize (GObject *object)
+gs_shell_overview_dispose (GObject *object)
{
GsShellOverview *shell = GS_SHELL_OVERVIEW (object);
GsShellOverviewPrivate *priv = shell->priv;
- g_object_unref (priv->builder);
- g_object_unref (priv->plugin_loader);
- g_object_unref (priv->cancellable);
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->plugin_loader);
+ g_clear_object (&priv->cancellable);
g_free (priv->category_of_day);
- G_OBJECT_CLASS (gs_shell_overview_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_overview_parent_class)->dispose (object);
}
static void
@@ -568,7 +568,7 @@ gs_shell_overview_class_init (GsShellOverviewClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_overview_finalize;
+ object_class->dispose = gs_shell_overview_dispose;
klass->refreshed = gs_shell_overview_refreshed;
signals [SIGNAL_REFRESHED] =
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index a1f2ee6..d8b40cd 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -406,28 +406,26 @@ gs_shell_search_setup (GsShellSearch *shell_search,
}
/**
- * gs_shell_search_finalize:
+ * gs_shell_search_dispose:
**/
static void
-gs_shell_search_finalize (GObject *object)
+gs_shell_search_dispose (GObject *object)
{
GsShellSearch *shell_search = GS_SHELL_SEARCH (object);
GsShellSearchPrivate *priv = shell_search->priv;
- g_object_unref (priv->sizegroup_image);
- g_object_unref (priv->sizegroup_name);
+ g_clear_object (&priv->sizegroup_image);
+ g_clear_object (&priv->sizegroup_name);
- g_object_unref (priv->builder);
- g_object_unref (priv->plugin_loader);
- g_object_unref (priv->cancellable);
-
- if (priv->search_cancellable != NULL)
- g_object_unref (priv->search_cancellable);
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->plugin_loader);
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->search_cancellable);
g_free (priv->appid_to_show);
g_free (priv->value);
- G_OBJECT_CLASS (gs_shell_search_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_search_parent_class)->dispose (object);
}
/**
@@ -440,7 +438,7 @@ gs_shell_search_class_init (GsShellSearchClass *klass)
GsPageClass *page_class = GS_PAGE_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_search_finalize;
+ object_class->dispose = gs_shell_search_dispose;
page_class->app_installed = gs_shell_search_app_installed;
page_class->app_removed = gs_shell_search_app_removed;
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 6794d92..94c1805 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -960,27 +960,27 @@ gs_shell_updates_setup (GsShellUpdates *shell_updates,
}
/**
- * gs_shell_updates_finalize:
+ * gs_shell_updates_dispose:
**/
static void
-gs_shell_updates_finalize (GObject *object)
+gs_shell_updates_dispose (GObject *object)
{
GsShellUpdates *shell_updates = GS_SHELL_UPDATES (object);
GsShellUpdatesPrivate *priv = shell_updates->priv;
if (priv->cancellable_refresh != NULL) {
g_cancellable_cancel (priv->cancellable_refresh);
- g_object_unref (priv->cancellable_refresh);
+ g_clear_object (&priv->cancellable_refresh);
}
- g_object_unref (priv->builder);
- g_object_unref (priv->plugin_loader);
- g_object_unref (priv->cancellable);
- g_object_unref (priv->control);
- g_object_unref (priv->settings);
- g_object_unref (priv->desktop_settings);
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->plugin_loader);
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->control);
+ g_clear_object (&priv->settings);
+ g_clear_object (&priv->desktop_settings);
- G_OBJECT_CLASS (gs_shell_updates_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_updates_parent_class)->dispose (object);
}
/**
@@ -992,7 +992,7 @@ gs_shell_updates_class_init (GsShellUpdatesClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_shell_updates_finalize;
+ object_class->dispose = gs_shell_updates_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-shell-updates.ui");
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 0da7d26..ca9c2a1 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -771,20 +771,23 @@ gs_shell_show_details (GsShell *shell, const gchar *id)
}
/**
- * gs_shell_finalize:
+ * gs_shell_dispose:
**/
static void
-gs_shell_finalize (GObject *object)
+gs_shell_dispose (GObject *object)
{
GsShell *shell = GS_SHELL (object);
GsShellPrivate *priv = shell->priv;
- g_queue_free_full (priv->back_entry_stack, (GDestroyNotify) free_back_entry);
- g_object_unref (priv->builder);
- g_object_unref (priv->cancellable);
- g_object_unref (priv->plugin_loader);
+ if (priv->back_entry_stack != NULL) {
+ g_queue_free_full (priv->back_entry_stack, (GDestroyNotify) free_back_entry);
+ priv->back_entry_stack = NULL;
+ }
+ g_clear_object (&priv->builder);
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->plugin_loader);
- G_OBJECT_CLASS (gs_shell_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_shell_parent_class)->dispose (object);
}
/**
@@ -794,7 +797,7 @@ static void
gs_shell_class_init (GsShellClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_shell_finalize;
+ object_class->dispose = gs_shell_dispose;
signals [SIGNAL_LOADED] =
g_signal_new ("loaded",
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index b5eb951..806be74 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -396,7 +396,7 @@ set_plugin_loader (GsUpdateDialog *dialog, GsPluginLoader *plugin_loader)
}
static void
-gs_update_dialog_finalize (GObject *object)
+gs_update_dialog_dispose (GObject *object)
{
GsUpdateDialog *dialog = GS_UPDATE_DIALOG (object);
GsUpdateDialogPrivate *priv = gs_update_dialog_get_instance_private (dialog);
@@ -413,7 +413,7 @@ gs_update_dialog_finalize (GObject *object)
g_clear_object (&priv->plugin_loader);
- G_OBJECT_CLASS (gs_update_dialog_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_update_dialog_parent_class)->dispose (object);
}
static void
@@ -460,7 +460,7 @@ gs_update_dialog_class_init (GsUpdateDialogClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- object_class->finalize = gs_update_dialog_finalize;
+ object_class->dispose = gs_update_dialog_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-update-dialog.ui");
diff --git a/src/gs-update-list.c b/src/gs-update-list.c
index 6fcc35f..88d99ce 100644
--- a/src/gs-update-list.c
+++ b/src/gs-update-list.c
@@ -169,7 +169,7 @@ list_sort_func (GtkListBoxRow *a,
}
static void
-gs_update_list_finalize (GObject *object)
+gs_update_list_dispose (GObject *object)
{
GsUpdateList *update_list = GS_UPDATE_LIST (object);
GsUpdateListPrivate *priv = gs_update_list_get_instance_private (update_list);
@@ -177,7 +177,7 @@ gs_update_list_finalize (GObject *object)
g_clear_object (&priv->sizegroup_image);
g_clear_object (&priv->sizegroup_name);
- G_OBJECT_CLASS (gs_update_list_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gs_update_list_parent_class)->dispose (object);
}
static void
@@ -201,7 +201,7 @@ gs_update_list_class_init (GsUpdateListClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gs_update_list_finalize;
+ object_class->dispose = gs_update_list_dispose;
}
GtkWidget *
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 1bf2eaf..9b743eb 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -530,7 +530,7 @@ gs_update_monitor_init (GsUpdateMonitor *monitor)
}
static void
-gs_update_monitor_finalize (GObject *object)
+gs_update_monitor_dispose (GObject *object)
{
GsUpdateMonitor *monitor = GS_UPDATE_MONITOR (object);
@@ -567,6 +567,15 @@ gs_update_monitor_finalize (GObject *object)
g_clear_object (&monitor->task);
g_clear_object (&monitor->offline_update_file);
g_clear_object (&monitor->settings);
+
+ G_OBJECT_CLASS (gs_update_monitor_parent_class)->dispose (object);
+}
+
+static void
+gs_update_monitor_finalize (GObject *object)
+{
+ GsUpdateMonitor *monitor = GS_UPDATE_MONITOR (object);
+
g_application_release (monitor->application);
G_OBJECT_CLASS (gs_update_monitor_parent_class)->finalize (object);
@@ -576,6 +585,7 @@ static void
gs_update_monitor_class_init (GsUpdateMonitorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gs_update_monitor_dispose;
object_class->finalize = gs_update_monitor_finalize;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]