Plug a dynamic leak
A leak occured in the timer code, and thus the memory was growing over time. Cf. src/task-manager.c(model_update_tree_iter), the old_state variable was not free'd. Plugged other static leaks at the same time.
This commit is contained in:
@@ -140,6 +140,9 @@ int main (int argc, char *argv[])
|
||||
if (timeout > 0)
|
||||
g_source_remove (timeout);
|
||||
g_object_unref (window);
|
||||
g_object_unref (status_icon);
|
||||
g_object_unref (task_manager);
|
||||
g_object_unref (settings);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ struct _XtmProcessStatusbar
|
||||
};
|
||||
G_DEFINE_TYPE (XtmProcessStatusbar, xtm_process_statusbar, GTK_TYPE_STATUSBAR)
|
||||
|
||||
static void xtm_process_statusbar_finalize (GObject *object);
|
||||
static void xtm_process_statusbar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
|
||||
|
||||
|
||||
@@ -60,6 +61,7 @@ xtm_process_statusbar_class_init (XtmProcessStatusbarClass *klass)
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_CLASS (klass);
|
||||
xtm_process_statusbar_parent_class = g_type_class_peek_parent (klass);
|
||||
class->finalize = xtm_process_statusbar_finalize;
|
||||
class->set_property = xtm_process_statusbar_set_property;
|
||||
g_object_class_install_property (class, PROP_CPU,
|
||||
g_param_spec_float ("cpu", "CPU", "CPU usage", 0, 100, 0, G_PARAM_CONSTRUCT|G_PARAM_WRITABLE));
|
||||
@@ -116,6 +118,13 @@ xtm_process_statusbar_init (XtmProcessStatusbar *statusbar)
|
||||
gtk_widget_show_all (hbox);
|
||||
}
|
||||
|
||||
static void
|
||||
xtm_process_statusbar_finalize (GObject *object)
|
||||
{
|
||||
g_object_unref (XTM_PROCESS_STATUSBAR (object)->settings);
|
||||
G_OBJECT_CLASS (xtm_process_statusbar_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
rounded_float_value (gfloat value, XtmSettings *settings)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,8 @@ struct _XtmProcessTreeView
|
||||
};
|
||||
G_DEFINE_TYPE (XtmProcessTreeView, xtm_process_tree_view, GTK_TYPE_TREE_VIEW)
|
||||
|
||||
static void xtm_process_tree_view_finalize (GObject *object);
|
||||
|
||||
static gboolean treeview_clicked (XtmProcessTreeView *treeview, GdkEventButton *event);
|
||||
static void columns_changed (XtmProcessTreeView *treeview);
|
||||
static void read_columns_positions (XtmProcessTreeView *treeview);
|
||||
@@ -69,7 +71,9 @@ static void settings_changed (GObject *object, GParamSpec *pspec, XtmProcess
|
||||
static void
|
||||
xtm_process_tree_view_class_init (XtmProcessTreeViewClass *klass)
|
||||
{
|
||||
GObjectClass *class = G_OBJECT_CLASS (klass);
|
||||
xtm_process_tree_view_parent_class = g_type_class_peek_parent (klass);
|
||||
class->finalize = xtm_process_tree_view_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -85,6 +89,7 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
|
||||
{
|
||||
gchar *uid_name;
|
||||
get_owner_uid (&treeview->owner_uid, &uid_name);
|
||||
g_free (uid_name);
|
||||
g_object_get (treeview->settings, "show-all-processes", &treeview->show_all_processes_cached, NULL);
|
||||
}
|
||||
|
||||
@@ -205,6 +210,31 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
|
||||
g_signal_connect (treeview, "button-press-event", G_CALLBACK (treeview_clicked), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
xtm_process_tree_view_finalize (GObject *object)
|
||||
{
|
||||
XtmProcessTreeView *treeview = XTM_PROCESS_TREE_VIEW (object);
|
||||
|
||||
if (GTK_IS_TREE_MODEL (treeview->model))
|
||||
{
|
||||
g_object_unref (treeview->model);
|
||||
treeview->model = NULL;
|
||||
}
|
||||
|
||||
if (GTK_IS_TREE_MODEL (treeview->model_filter))
|
||||
{
|
||||
g_object_unref (treeview->model_filter);
|
||||
treeview->model_filter = NULL;
|
||||
}
|
||||
|
||||
if (XTM_IS_SETTINGS (treeview->settings))
|
||||
{
|
||||
g_object_unref (treeview->settings);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xtm_process_tree_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions
|
||||
*/
|
||||
|
||||
@@ -147,10 +147,14 @@ xtm_process_window_finalize (GObject *object)
|
||||
"sort-column-id", sort_column_id, "sort-type", sort_type, NULL);
|
||||
}
|
||||
|
||||
if (GTK_IS_TREE_VIEW (priv->treeview))
|
||||
gtk_widget_destroy (priv->treeview);
|
||||
|
||||
if (GTK_IS_STATUSBAR (priv->statusbar))
|
||||
gtk_widget_destroy (priv->statusbar);
|
||||
|
||||
if (XTM_IS_SETTINGS (priv->settings))
|
||||
{
|
||||
g_object_unref (priv->settings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -198,7 +198,7 @@ xtm_settings_load_settings (XtmSettings *settings)
|
||||
|
||||
if (g_key_file_load_from_file (rc, filename, G_KEY_FILE_NONE, NULL))
|
||||
{
|
||||
const gchar *string;
|
||||
gchar *string;
|
||||
GValue dst = {0};
|
||||
GValue src = {0};
|
||||
GParamSpec **specs;
|
||||
@@ -215,7 +215,8 @@ xtm_settings_load_settings (XtmSettings *settings)
|
||||
continue;
|
||||
|
||||
g_value_init (&src, G_TYPE_STRING);
|
||||
g_value_set_static_string (&src, string);
|
||||
g_value_set_string (&src, string);
|
||||
g_free (string);
|
||||
|
||||
if (spec->value_type == G_TYPE_STRING)
|
||||
{
|
||||
|
||||
@@ -266,6 +266,7 @@ model_update_tree_iter (GtkTreeModel *model, GtkTreeIter *iter, Task *task)
|
||||
|
||||
g_free (background);
|
||||
g_free (foreground);
|
||||
g_free (old_state);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user