[gnome-menus/wip/gobject-review] libmenu: Fix loading of .directory files
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-menus/wip/gobject-review] libmenu: Fix loading of .directory files
- Date: Sun, 12 Jun 2011 10:50:23 +0000 (UTC)
commit 8a3c229d9f12159fb54ca3d1c187289714fabc97
Author: Vincent Untz <vuntz gnome org>
Date: Sun Jun 12 12:38:30 2011 +0200
libmenu: Fix loading of .directory files
We were always returning FALSE, leaking some data and not displaying a
debug message in case of error (like for .desktop files).
libmenu/desktop-entries.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/libmenu/desktop-entries.c b/libmenu/desktop-entries.c
index eed0e62..4d30c7d 100644
--- a/libmenu/desktop-entries.c
+++ b/libmenu/desktop-entries.c
@@ -183,10 +183,6 @@ desktop_entry_load_directory (DesktopEntry *entry,
static gboolean
desktop_entry_load (DesktopEntry *entry)
{
- GKeyFile *key_file;
- GError *error = NULL;
- gboolean retval = FALSE;
-
if (entry->type == DESKTOP_ENTRY_DESKTOP)
{
DesktopEntryDesktop *entry_desktop = (DesktopEntryDesktop*)entry;
@@ -218,6 +214,10 @@ desktop_entry_load (DesktopEntry *entry)
}
else if (entry->type == DESKTOP_ENTRY_DIRECTORY)
{
+ GKeyFile *key_file = NULL;
+ GError *error = NULL;
+ gboolean retval = FALSE;
+
key_file = g_key_file_new ();
if (!g_key_file_load_from_file (key_file, entry->path, 0, &error))
@@ -226,13 +226,28 @@ desktop_entry_load (DesktopEntry *entry)
if (!desktop_entry_load_directory (entry, key_file, &error))
goto out;
+ retval = TRUE;
+
+ out:
g_key_file_free (key_file);
+
+ if (!retval)
+ {
+ if (error)
+ {
+ menu_verbose ("Failed to load \"%s\": %s\n", entry->path, error->message);
+ g_error_free (error);
+ }
+ else
+ menu_verbose ("Failed to load \"%s\"\n", entry->path);
+ }
+
+ return retval;
}
else
g_assert_not_reached ();
-
- out:
- return retval;
+
+ return FALSE;
}
DesktopEntry *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]