mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
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.
This commit is contained in:
parent
d7d782be1c
commit
f18bd86ab8
1 changed files with 9 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue