summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Schermer <nick@xfce.org>2012-10-05 23:12:22 +0200
committerNick Schermer <nick@xfce.org>2012-10-13 16:10:34 +0200
commit20ce6724810584ba88e66afd8ba7b8bdd8cc86ae (patch)
tree9564eceabab1668000418c37049d7105c35dcd7f
parente486a39069ea5ac99e59db74064f70037417053c (diff)
downloadthunar-20ce6724810584ba88e66afd8ba7b8bdd8cc86ae.tar.gz
Handle NULL ThunarFiles.
-rw-r--r--thunar/thunar-shortcuts-model.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index c16988c4..3d4ba1dd 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -310,6 +310,7 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
GFile *bookmarks;
GFile *desktop;
GFile *trash;
+ ThunarFile *file;
/* add the places heading */
shortcut = g_slice_new0 (ThunarShortcut);
@@ -322,23 +323,31 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
home = thunar_g_file_new_for_home ();
/* add home entry */
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
- shortcut->file = thunar_file_get (home, NULL);
- shortcut->sort_id = 0;
- shortcut->gicon = g_themed_icon_new ("user-home");
- thunar_shortcuts_model_add_shortcut (model, shortcut);
+ file = thunar_file_get (home, NULL);
+ if (file != NULL)
+ {
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
+ shortcut->file = file;
+ shortcut->sort_id = 0;
+ shortcut->gicon = g_themed_icon_new ("user-home");
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
/* add desktop entry */
desktop = thunar_g_file_new_for_desktop ();
if (!g_file_equal (desktop, home))
{
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
- shortcut->file = thunar_file_get (desktop, NULL);
- shortcut->gicon = g_themed_icon_new ("user-desktop");
- shortcut->sort_id = 1;
- thunar_shortcuts_model_add_shortcut (model, shortcut);
+ file = thunar_file_get (desktop, NULL);
+ if (file != NULL)
+ {
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES;
+ shortcut->file = file;
+ shortcut->gicon = g_themed_icon_new ("user-desktop");
+ shortcut->sort_id = 1;
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
}
g_object_unref (desktop);
@@ -346,15 +355,18 @@ thunar_shortcuts_model_shortcut_places (ThunarShortcutsModel *model)
if (thunar_g_vfs_is_uri_scheme_supported ("trash"))
{
trash = thunar_g_file_new_for_trash ();
-
- shortcut = g_slice_new0 (ThunarShortcut);
- shortcut->group = THUNAR_SHORTCUT_GROUP_TRASH;
- shortcut->file = thunar_file_get (trash, NULL);
- shortcut->gicon = g_themed_icon_new ("user-trash");
- shortcut->name = g_strdup (_("Trash"));
- thunar_shortcuts_model_add_shortcut (model, shortcut);
-
+ file = thunar_file_get (trash, NULL);
g_object_unref (trash);
+
+ if (file != NULL)
+ {
+ shortcut = g_slice_new0 (ThunarShortcut);
+ shortcut->group = THUNAR_SHORTCUT_GROUP_TRASH;
+ shortcut->file = file;
+ shortcut->gicon = g_themed_icon_new ("user-trash");
+ shortcut->name = g_strdup (_("Trash"));
+ thunar_shortcuts_model_add_shortcut (model, shortcut);
+ }
}
/* determine the URI to the Gtk+ bookmarks file */
@@ -1084,6 +1096,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model)
file = thunar_file_get (file_path, NULL);
g_object_unref (file_path);
+ /* TODO invisible item? */
if (G_UNLIKELY (file == NULL))
continue;