mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Fixes File manager freezing on absent or empty SD
This commit is contained in:
parent
645a781ac2
commit
87cc3c89d5
@ -92,31 +92,37 @@ FileManBaseView::FileManBaseView(
|
|||||||
) : nav_ (nav),
|
) : nav_ (nav),
|
||||||
extension_filter { filter }
|
extension_filter { filter }
|
||||||
{
|
{
|
||||||
load_directory_contents(current_path);
|
|
||||||
|
|
||||||
if (!entry_list.size())
|
|
||||||
empty_root = true;
|
|
||||||
|
|
||||||
add_children({
|
add_children({
|
||||||
&labels,
|
&labels,
|
||||||
&text_current,
|
&text_current,
|
||||||
&button_exit
|
&button_exit
|
||||||
});
|
});
|
||||||
|
|
||||||
|
button_exit.on_select = [this, &nav](Button&) {
|
||||||
|
nav.pop();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!sdcIsCardInserted(&SDCD1)) {
|
||||||
|
empty_root=true;
|
||||||
|
text_current.set("NO SD CARD!");
|
||||||
|
} else {
|
||||||
|
load_directory_contents(current_path);
|
||||||
|
if (!entry_list.size())
|
||||||
|
{
|
||||||
|
empty_root = true;
|
||||||
|
text_current.set("EMPTY SD CARD!");
|
||||||
|
} else {
|
||||||
menu_view.on_left = [&nav, this]() {
|
menu_view.on_left = [&nav, this]() {
|
||||||
load_directory_contents(get_parent_dir());
|
load_directory_contents(get_parent_dir());
|
||||||
refresh_list();
|
refresh_list();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
button_exit.on_select = [this, &nav](Button&) {
|
}
|
||||||
nav.pop();
|
}
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
void FileManBaseView::focus() {
|
void FileManBaseView::focus() {
|
||||||
if (empty_root) {
|
if (empty_root) {
|
||||||
button_exit.focus();
|
button_exit.focus();
|
||||||
nav_.display_modal("Error", "No files in root.", ABORT, nullptr);
|
|
||||||
} else {
|
} else {
|
||||||
menu_view.focus();
|
menu_view.focus();
|
||||||
}
|
}
|
||||||
@ -190,7 +196,6 @@ void FileManBaseView::refresh_list() {
|
|||||||
nav_.pop();
|
nav_.pop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSaveView::FileSaveView(
|
FileSaveView::FileSaveView(
|
||||||
NavigationView& nav
|
NavigationView& nav
|
||||||
) : FileManBaseView(nav)
|
) : FileManBaseView(nav)
|
||||||
@ -271,6 +276,7 @@ FileManagerView::FileManagerView(
|
|||||||
NavigationView& nav
|
NavigationView& nav
|
||||||
) : FileManBaseView(nav, "")
|
) : FileManBaseView(nav, "")
|
||||||
{
|
{
|
||||||
|
if (!empty_root) {
|
||||||
on_refresh_widgets = [this](bool v) {
|
on_refresh_widgets = [this](bool v) {
|
||||||
refresh_widgets(v);
|
refresh_widgets(v);
|
||||||
};
|
};
|
||||||
@ -323,5 +329,6 @@ FileManagerView::FileManagerView(
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user