Fix more memory leaks
Found by Valgrind when starting xfce4-taskmanager.
This commit is contained in:
@@ -225,8 +225,11 @@ int main (int argc, char *argv[])
|
|||||||
if (!g_option_context_parse (opt_context, &argc, &argv, &error))
|
if (!g_option_context_parse (opt_context, &argc, &argv, &error))
|
||||||
{
|
{
|
||||||
g_print ("Unable to parse arguments: %s\n", error->message);
|
g_print ("Unable to parse arguments: %s\n", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
g_option_context_free (opt_context);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
g_option_context_free (opt_context);
|
||||||
|
|
||||||
app = g_application_new ("xfce.taskmanager", 0);
|
app = g_application_new ("xfce.taskmanager", 0);
|
||||||
g_application_register (G_APPLICATION (app), NULL, &error);
|
g_application_register (G_APPLICATION (app), NULL, &error);
|
||||||
|
|||||||
@@ -91,6 +91,19 @@ xtm_cross_link_new (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
xtm_cross_link_free (gpointer data)
|
||||||
|
{
|
||||||
|
XtmCrossLink *lnk = data;
|
||||||
|
|
||||||
|
if (lnk != NULL && lnk->path != NULL)
|
||||||
|
gtk_tree_path_free (lnk->path);
|
||||||
|
|
||||||
|
g_free (lnk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xtm_process_tree_model_class_init (XtmProcessTreeModelClass *klass)
|
xtm_process_tree_model_class_init (XtmProcessTreeModelClass *klass)
|
||||||
{
|
{
|
||||||
@@ -132,7 +145,7 @@ xtm_process_tree_model_iface_init (GtkTreeModelIface *iface)
|
|||||||
static void
|
static void
|
||||||
xtm_process_tree_model_init (XtmProcessTreeModel *treemodel)
|
xtm_process_tree_model_init (XtmProcessTreeModel *treemodel)
|
||||||
{
|
{
|
||||||
treemodel->list = g_sequence_new (g_free);
|
treemodel->list = g_sequence_new (xtm_cross_link_free);
|
||||||
treemodel->tree = g_node_new (NULL);
|
treemodel->tree = g_node_new (NULL);
|
||||||
|
|
||||||
treemodel->c_column = XTM_PTV_COLUMN_PID;
|
treemodel->c_column = XTM_PTV_COLUMN_PID;
|
||||||
@@ -883,7 +896,7 @@ xtm_process_tree_model_rows_reordered (XtmProcessTreeModel *treemodel, GtkTreePa
|
|||||||
not_persist = ! (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_ITERS_PERSIST);
|
not_persist = ! (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_ITERS_PERSIST);
|
||||||
|
|
||||||
/* New list to hold the new order */
|
/* New list to hold the new order */
|
||||||
s_list = g_sequence_new (g_free);
|
s_list = g_sequence_new (xtm_cross_link_free);
|
||||||
s_iter = g_sequence_get_end_iter (s_list);
|
s_iter = g_sequence_get_end_iter (s_list);
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
|
|||||||
@@ -259,7 +259,9 @@ model_update_tree_iter (XtmTaskManager *manager, GtkTreeIter *iter, glong timest
|
|||||||
-1);
|
-1);
|
||||||
|
|
||||||
#ifdef HAVE_WNCK
|
#ifdef HAVE_WNCK
|
||||||
if (app != NULL && icon == NULL)
|
if (icon != NULL)
|
||||||
|
g_object_unref (icon);
|
||||||
|
else if (app != NULL)
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), iter, XTM_PTV_COLUMN_ICON, app->icon, -1);
|
gtk_list_store_set (GTK_LIST_STORE (model), iter, XTM_PTV_COLUMN_ICON, app->icon, -1);
|
||||||
|
|
||||||
if (app != NULL && full_cmdline == FALSE)
|
if (app != NULL && full_cmdline == FALSE)
|
||||||
@@ -281,6 +283,8 @@ model_update_tree_iter (XtmTaskManager *manager, GtkTreeIter *iter, glong timest
|
|||||||
if (g_strcmp0 (task->state, old_state) != 0 && background == NULL)
|
if (g_strcmp0 (task->state, old_state) != 0 && background == NULL)
|
||||||
{
|
{
|
||||||
/* Set yellow color for changing state */
|
/* Set yellow color for changing state */
|
||||||
|
g_free (background);
|
||||||
|
g_free (foreground);
|
||||||
background = g_strdup ("#fff176");
|
background = g_strdup ("#fff176");
|
||||||
foreground = g_strdup ("#000000");
|
foreground = g_strdup ("#000000");
|
||||||
old_timestamp = timestamp - TIMESTAMP_DELTA + 3;
|
old_timestamp = timestamp - TIMESTAMP_DELTA + 3;
|
||||||
@@ -295,6 +299,8 @@ model_update_tree_iter (XtmTaskManager *manager, GtkTreeIter *iter, glong timest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Reset color */
|
/* Reset color */
|
||||||
|
g_free (background);
|
||||||
|
g_free (foreground);
|
||||||
background = NULL;
|
background = NULL;
|
||||||
foreground = NULL;
|
foreground = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user