Properly finalize global objects in main
This commit is contained in:
@@ -92,6 +92,8 @@ static void
|
|||||||
xtm_app_manager_finalize (GObject *object)
|
xtm_app_manager_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
g_array_free (XTM_APP_MANAGER (object)->apps, TRUE);
|
g_array_free (XTM_APP_MANAGER (object)->apps, TRUE);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xtm_app_manager_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GPid
|
static GPid
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ int main (int argc, char *argv[])
|
|||||||
xtm_settings_bind_xfconf (settings, channel);
|
xtm_settings_bind_xfconf (settings, channel);
|
||||||
show_hide_status_icon ();
|
show_hide_status_icon ();
|
||||||
|
|
||||||
window = xtm_process_window_new ();
|
window = g_object_ref_sink (xtm_process_window_new ());
|
||||||
|
|
||||||
if (!start_hidden)
|
if (!start_hidden)
|
||||||
gtk_widget_show (window);
|
gtk_widget_show (window);
|
||||||
@@ -288,6 +288,11 @@ int main (int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
g_warning ("Nothing to do: activate hiding to the notification area when using --start-hidden");
|
g_warning ("Nothing to do: activate hiding to the notification area when using --start-hidden");
|
||||||
|
|
||||||
|
g_object_unref (task_manager);
|
||||||
|
g_object_unref (window);
|
||||||
|
g_object_unref (settings);
|
||||||
|
if (status_icon_or_null != NULL)
|
||||||
|
g_object_unref (status_icon_or_null);
|
||||||
xfconf_shutdown();
|
xfconf_shutdown();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -388,17 +388,10 @@ xtm_process_window_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
XtmProcessWindow *window = XTM_PROCESS_WINDOW (object);
|
XtmProcessWindow *window = XTM_PROCESS_WINDOW (object);
|
||||||
|
|
||||||
if (GTK_IS_TREE_VIEW (window->treeview))
|
g_object_unref (window->settings);
|
||||||
gtk_widget_destroy (window->treeview);
|
|
||||||
|
|
||||||
if (GTK_IS_BOX (window->statusbar))
|
|
||||||
gtk_widget_destroy (window->statusbar);
|
|
||||||
|
|
||||||
if (XTM_IS_SETTINGS (window->settings))
|
|
||||||
g_object_unref (window->settings);
|
|
||||||
|
|
||||||
g_object_unref (window->builder);
|
g_object_unref (window->builder);
|
||||||
window->builder = NULL;
|
|
||||||
|
G_OBJECT_CLASS (xtm_process_window_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ G_DEFINE_TYPE (XtmSettings, xtm_settings, G_TYPE_OBJECT)
|
|||||||
|
|
||||||
static void xtm_settings_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
|
static void xtm_settings_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
|
||||||
static void xtm_settings_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
|
static void xtm_settings_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
|
||||||
|
static void xtm_settings_finalize (GObject *object);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xtm_settings_class_init (XtmSettingsClass *klass)
|
xtm_settings_class_init (XtmSettingsClass *klass)
|
||||||
@@ -82,6 +83,7 @@ xtm_settings_class_init (XtmSettingsClass *klass)
|
|||||||
xtm_settings_parent_class = g_type_class_peek_parent (klass);
|
xtm_settings_parent_class = g_type_class_peek_parent (klass);
|
||||||
class->get_property = xtm_settings_get_property;
|
class->get_property = xtm_settings_get_property;
|
||||||
class->set_property = xtm_settings_set_property;
|
class->set_property = xtm_settings_set_property;
|
||||||
|
class->finalize = xtm_settings_finalize;
|
||||||
g_object_class_install_property (class, PROP_SHOW_ALL_PROCESSES,
|
g_object_class_install_property (class, PROP_SHOW_ALL_PROCESSES,
|
||||||
g_param_spec_boolean ("show-all-processes", "ShowAllProcesses", "Show all processes", FALSE, G_PARAM_READWRITE));
|
g_param_spec_boolean ("show-all-processes", "ShowAllProcesses", "Show all processes", FALSE, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (class, PROP_SHOW_LEGEND,
|
g_object_class_install_property (class, PROP_SHOW_LEGEND,
|
||||||
@@ -155,6 +157,20 @@ xtm_settings_set_property (GObject *object, guint property_id, const GValue *val
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xtm_settings_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
XtmSettings *settings = XTM_SETTINGS (object);
|
||||||
|
|
||||||
|
for (gint i = 0; i < N_PROPS; i++)
|
||||||
|
{
|
||||||
|
if (G_IS_VALUE (settings->values + i))
|
||||||
|
g_value_unset (settings->values + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xtm_settings_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xtm_settings_bind_xfconf (XtmSettings *settings, XfconfChannel *channel)
|
xtm_settings_bind_xfconf (XtmSettings *settings, XfconfChannel *channel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ xtm_task_manager_finalize (GObject *object)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (xtm_task_manager_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user