summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-04-28 15:46:02 +0200
committerYorhel <git@yorhel.nl>2010-04-28 15:48:57 +0200
commitf18bd86ab82e79d02e09533b3f4c90356a352366 (patch)
tree9bf2488d4bddb3d0a4eb1b29dc48a362cba62ebf
parentd7d782be1cd2a5c127f6d5be1ccc150f2c7d6130 (diff)
Got rid of segfault when the root dir only contains hidden files
Instead you now get the usual 'no items to display' message when hiding hidden files in the root directory.
-rw-r--r--src/dirlist.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/dirlist.c b/src/dirlist.c
index db0bd0d..6fbe07f 100644
--- a/src/dirlist.c
+++ b/src/dirlist.c
@@ -170,10 +170,9 @@ void dirlist_fixup() {
}
/* no selected items found after one pass? select the first visible item */
- if(!selected) {
- selected = dirlist_next(NULL);
- selected->flags |= FF_BSEL;
- }
+ if(!selected)
+ if((selected = dirlist_next(NULL)))
+ selected->flags |= FF_BSEL;
}
@@ -239,13 +238,17 @@ struct dir *dirlist_prev(struct dir *d) {
}
-/* this function assumes that 'selected' is valid and points to a visible item */
struct dir *dirlist_get(int i) {
struct dir *t = selected, *d;
if(!head)
return NULL;
+ if(ISHIDDEN(selected)) {
+ selected = dirlist_next(NULL);
+ return selected;
+ }
+
/* i == 0? return the selected item */
if(!i)
return selected;
@@ -273,7 +276,7 @@ struct dir *dirlist_get(int i) {
void dirlist_select(struct dir *d) {
- if(!head || ISHIDDEN(d) || d->parent != head->parent)
+ if(!d || !head || ISHIDDEN(d) || d->parent != head->parent)
return;
selected->flags &= ~FF_BSEL;