Skip to content

Commit

Permalink
Workbench: fixed not closed file handles on directory scanning (thank…
Browse files Browse the repository at this point in the history
…s to techee). Fixes #607.
  • Loading branch information
lpaulsen93 committed Oct 2, 2017
1 parent c295977 commit daa71c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion workbench/src/plugin_main.c
Expand Up @@ -128,7 +128,7 @@ void geany_load_module(GeanyPlugin *plugin)
/* Set metadata */
plugin->info->name = _("Workbench");
plugin->info->description = _("Manage and customize multiple projects.");
plugin->info->version = "1.0";
plugin->info->version = "1.01";
plugin->info->author = "LarsGit223";

/* Set functions */
Expand Down
16 changes: 11 additions & 5 deletions workbench/src/wb_project.c
Expand Up @@ -228,6 +228,9 @@ static GSList *wb_project_dir_get_file_list(WB_PROJECT_DIR *root, const gchar *u
{
GSList *list = NULL;
GDir *dir;
const gchar *child_name;
GSList *child;
GSList *children = NULL;
gchar *locale_path = utils_get_locale_from_utf8(utf8_path);
gchar *real_path = utils_get_real_path(locale_path);

Expand All @@ -245,14 +248,17 @@ static GSList *wb_project_dir_get_file_list(WB_PROJECT_DIR *root, const gchar *u

g_hash_table_insert(visited_paths, real_path, GINT_TO_POINTER(1));

while (TRUE)
while ((child_name = g_dir_read_name(dir)))
children = g_slist_prepend(children, g_strdup(child_name));

g_dir_close(dir);

foreach_slist(child, children)
{
const gchar *locale_name;
gchar *locale_filename, *utf8_filename, *utf8_name;

locale_name = g_dir_read_name(dir);
if (!locale_name)
break;
locale_name = child->data;

utf8_name = utils_get_utf8_from_locale(locale_name);
locale_filename = g_build_filename(locale_path, locale_name, NULL);
Expand Down Expand Up @@ -287,7 +293,7 @@ static GSList *wb_project_dir_get_file_list(WB_PROJECT_DIR *root, const gchar *u
g_free(utf8_name);
}

g_dir_close(dir);
g_slist_free_full(children, g_free);
g_free(locale_path);

return list;
Expand Down

0 comments on commit daa71c6

Please sign in to comment.