Revision: 1662 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1662&view=re... Author: dimitrov-adrian Date: 2010-10-16 22:18:18 +0000 (Sat, 16 Oct 2010)
Log Message: ----------- Treebrowser: Refactor a bit check_hidden() not to leak memory (Patch by Colomban Wendling)
Modified Paths: -------------- trunk/geany-plugins/treebrowser/ChangeLog trunk/geany-plugins/treebrowser/README trunk/geany-plugins/treebrowser/src/treebrowser.c
Modified: trunk/geany-plugins/treebrowser/ChangeLog =================================================================== --- trunk/geany-plugins/treebrowser/ChangeLog 2010-10-16 19:19:43 UTC (rev 1661) +++ trunk/geany-plugins/treebrowser/ChangeLog 2010-10-16 22:18:18 UTC (rev 1662) @@ -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 @@ -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
Modified: trunk/geany-plugins/treebrowser/README =================================================================== --- trunk/geany-plugins/treebrowser/README 2010-10-16 19:19:43 UTC (rev 1661) +++ trunk/geany-plugins/treebrowser/README 2010-10-16 22:18:18 UTC (rev 1662) @@ -31,6 +31,7 @@ Requirements ============ * GTK >= 2.8.0 + * GIO >= 2.0 (optional) * Geany >= 0.17
Modified: trunk/geany-plugins/treebrowser/src/treebrowser.c =================================================================== --- trunk/geany-plugins/treebrowser/src/treebrowser.c 2010-10-16 19:19:43 UTC (rev 1661) +++ trunk/geany-plugins/treebrowser/src/treebrowser.c 2010-10-16 22:18:18 UTC (rev 1662) @@ -251,41 +251,32 @@ 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) + info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN, 0, NULL, NULL); + if (info) { - 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 - { - 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; - } -#else - return TRUE; -#endif + g_object_unref(file); +# endif /* HAVE_GIO */ +#else /* G_OS_WIN32 */ + gchar *base_name;
-#else - if (g_path_get_basename(uri)[0] == '.') - return FALSE; - return TRUE; + base_name = g_path_get_basename(uri); + if (base_name[0] == '.') + is_visible = FALSE; + g_free(base_name); #endif + + return is_visible; }
static gchar*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.