diff --git a/projectorganizer/src/prjorg-main.c b/projectorganizer/src/prjorg-main.c index 538bc389e..2216db998 100644 --- a/projectorganizer/src/prjorg-main.c +++ b/projectorganizer/src/prjorg-main.c @@ -134,7 +134,6 @@ static void on_project_open(G_GNUC_UNUSED GObject * obj, GKeyFile * config, prjorg_sidebar_update_full(TRUE, arr); prjorg_sidebar_activate(TRUE); prjorg_menu_activate_menu_items(TRUE); - g_strfreev(arr); } } diff --git a/projectorganizer/src/prjorg-project.c b/projectorganizer/src/prjorg-project.c index bb5ae7757..1eb030b94 100644 --- a/projectorganizer/src/prjorg-project.c +++ b/projectorganizer/src/prjorg-project.c @@ -380,17 +380,11 @@ static void update_project( static void save_expanded_paths(GKeyFile * key_file) { - GPtrArray *expanded_paths = prjorg_sidebar_get_expanded_paths(); - gchar **expanded_paths_v = g_new (gchar *, expanded_paths->len + 1); - guint i; + gchar **expanded_paths = prjorg_sidebar_get_expanded_paths(); - for (i = 0; i < expanded_paths->len; i++) - expanded_paths_v[i] = expanded_paths->pdata[i]; - expanded_paths_v[expanded_paths->len] = NULL; g_key_file_set_string_list(key_file, "prjorg", "expanded_paths", - (const gchar**) expanded_paths_v, g_strv_length(expanded_paths_v)); - g_free(expanded_paths_v); - g_ptr_array_free(expanded_paths, TRUE); + (const gchar**) expanded_paths, g_strv_length(expanded_paths)); + g_strfreev(expanded_paths); } diff --git a/projectorganizer/src/prjorg-sidebar.c b/projectorganizer/src/prjorg-sidebar.c index 037d2e0ad..b23baea52 100644 --- a/projectorganizer/src/prjorg-sidebar.c +++ b/projectorganizer/src/prjorg-sidebar.c @@ -51,7 +51,7 @@ typedef enum typedef struct { GeanyProject *project; - GPtrArray *expanded_paths; + gchar **expanded_paths; gchar *selected_path; } ExpandData; @@ -1397,12 +1397,10 @@ static gboolean expand_on_idle(ExpandData *expand_data) if (geany_data->app->project == expand_data->project && expand_data->expanded_paths) { - gchar *item; - guint i; - - foreach_ptr_array(item, i, expand_data->expanded_paths) - expand_path(item, FALSE); - g_ptr_array_free(expand_data->expanded_paths, TRUE); + gchar **item; + foreach_strv(item, expand_data->expanded_paths) + expand_path(*item, FALSE); + g_strfreev(expand_data->expanded_paths); } if (expand_data->selected_path) @@ -1457,14 +1455,15 @@ static void on_map_expanded(GtkTreeView *tree_view, GtkTreePath *tree_path, GPtr } -GPtrArray *prjorg_sidebar_get_expanded_paths(void) +gchar **prjorg_sidebar_get_expanded_paths(void) { - GPtrArray *expanded_paths = g_ptr_array_new_with_free_func(g_free); + GPtrArray *expanded_paths = g_ptr_array_new(); gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(s_file_view), (GtkTreeViewMappingFunc)on_map_expanded, expanded_paths); + g_ptr_array_add(expanded_paths, NULL); - return expanded_paths; + return g_ptr_array_free(expanded_paths, FALSE); } @@ -1492,15 +1491,8 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths) GtkTreeSelection *treesel; GtkTreeIter iter; GtkTreeModel *model; - gchar **path; - GPtrArray *exp_paths_arr = g_ptr_array_new(); - - foreach_strv (path, expanded_paths) - { - g_ptr_array_add(exp_paths_arr, g_strdup(*path)); - } - expand_data->expanded_paths = expanded_paths != NULL ? exp_paths_arr : prjorg_sidebar_get_expanded_paths(); + expand_data->expanded_paths = expanded_paths != NULL ? expanded_paths : prjorg_sidebar_get_expanded_paths(); expand_data->selected_path = get_selected_path(); load_project(); diff --git a/projectorganizer/src/prjorg-sidebar.h b/projectorganizer/src/prjorg-sidebar.h index 00657389e..3b42c6375 100644 --- a/projectorganizer/src/prjorg-sidebar.h +++ b/projectorganizer/src/prjorg-sidebar.h @@ -32,6 +32,6 @@ void prjorg_sidebar_update_full(gboolean reload, gchar **expanded_paths); void prjorg_sidebar_focus_project_tab(void); -GPtrArray *prjorg_sidebar_get_expanded_paths(void); +gchar **prjorg_sidebar_get_expanded_paths(void); #endif