[gnome-shell] Check the type of GMenu items we get to avoid a crash
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-shell] Check the type of GMenu items we get to avoid a crash
- Date: Wed, 8 Apr 2009 10:55:11 -0400 (EDT)
commit df1e05120795707b3797775c6a33c56aef57b42d
Author: Colin Walters <walters verbum org>
Date: Wed Apr 8 10:54:27 2009 -0400
Check the type of GMenu items we get to avoid a crash
We can't assume they're entries, and in this case they were
actually directories.
---
src/shell-app-monitor.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c
index 5708290..70ce10d 100644
--- a/src/shell-app-monitor.c
+++ b/src/shell-app-monitor.c
@@ -111,16 +111,27 @@ reread_menus (ShellAppMonitor *self)
for (iter = entries; iter; iter = iter->next)
{
- GMenuTreeEntry *entry = iter->data;
- ShellAppMenuEntry *shell_entry = g_new0 (ShellAppMenuEntry, 1);
+ GMenuTreeItem *item = iter->data;
+
+ switch (gmenu_tree_item_get_type (item))
+ {
+ case GMENU_TREE_ITEM_DIRECTORY:
+ {
+ GMenuTreeDirectory *dir = iter->data;
+ ShellAppMenuEntry *shell_entry = g_new0 (ShellAppMenuEntry, 1);
- shell_entry->name = g_strdup (gmenu_tree_entry_get_name (entry));
- shell_entry->id = g_strdup (gmenu_tree_entry_get_desktop_file_id (entry));
- shell_entry->icon = g_strdup (gmenu_tree_entry_get_icon (entry));
+ shell_entry->name = g_strdup (gmenu_tree_directory_get_name (dir));
+ shell_entry->id = g_strdup (gmenu_tree_directory_get_menu_id (dir));
+ shell_entry->icon = g_strdup (gmenu_tree_directory_get_icon (dir));
- priv->cached_menus = g_list_prepend (priv->cached_menus, shell_entry);
+ priv->cached_menus = g_list_prepend (priv->cached_menus, shell_entry);
- gmenu_tree_item_unref (entry);
+ gmenu_tree_item_unref (dir);
+ }
+ break;
+ default:
+ break;
+ }
}
priv->cached_menus = g_list_reverse (priv->cached_menus);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]