Skip to content

Commit

Permalink
Treebrowser: Refactor a bit check_hidden() not to leak memory (Patch …
Browse files Browse the repository at this point in the history
…by Colomban Wendling)

git-svn-id: https://geany-plugins.svn.sourceforge.net/svnroot/geany-plugins/trunk/geany-plugins@1662 e8383189-8249-0410-b506-acc975200cbd
  • Loading branch information
dimitrov-adrian committed Oct 16, 2010
1 parent 10cc9e4 commit 38d56c0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
9 changes: 8 additions & 1 deletion treebrowser/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(DONE) oneclick document opening
(DONE) filter separating ex.: "*.c;*.cpp;*.h"
* Fix possible memory leaks (using g_free... where is need)
* Folowing path from current document view
* Complete following path from current document view
(DONE) Hide object files as native filebroser (*.o;*.a;*.so;*.dll;*.lib..)
(DONE) Using font from geany settings for sidebar
* Migrating to stash
Expand All @@ -38,6 +38,13 @@
+-------------------------------+


17-10-2010 Adrian Dimitrov <dimitrov.adrian@gmail.com>

* src/treebrowser.c
Refactor a bit check_hidden() not to leak memory
(Patch by Colomban Wendling)


16-10-2010 Adrian Dimitrov <dimitrov.adrian@gmail.com>

* src/treebrowser.c
Expand Down
1 change: 1 addition & 0 deletions treebrowser/README
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Features
Requirements
============
* GTK >= 2.8.0
* GIO >= 2.0 (optional)
* Geany >= 0.17


Expand Down
43 changes: 17 additions & 26 deletions treebrowser/src/treebrowser.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,41 +251,32 @@ check_hidden(const gchar *uri)
if (uri[strlen(uri) - 1] == '~')
return FALSE;

gboolean is_visible = TRUE;
#ifdef G_OS_WIN32
#ifdef HAVE_GIO
GError *error;
# ifdef HAVE_GIO
GFile *file;
GFileInfo *info;

file = g_file_new_for_path(uri);
info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, 0, NULL, &error);
if (error)
{
g_error_free(error);
g_object_unref(file);
return TRUE;
}
else
info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, 0, NULL, NULL);
if (info)
{
if (g_file_info_get_is_hidden (info))
{
g_error_free(error);
g_object_unref(file);
return FALSE;
}
g_error_free(error);
g_object_unref(file);
return TRUE;
if (g_file_info_get_is_hidden(info))
is_visible = FALSE;
g_object_unref(info);
}
#else
return TRUE;
g_object_unref(file);
# endif /* HAVE_GIO */
#else /* G_OS_WIN32 */
gchar *base_name;

base_name = g_path_get_basename(uri);
if (base_name[0] == '.')
is_visible = FALSE;
g_free(base_name);
#endif

#else
if (g_path_get_basename(uri)[0] == '.')
return FALSE;
return TRUE;
#endif
return is_visible;
}

static gchar*
Expand Down

0 comments on commit 38d56c0

Please sign in to comment.