mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
LibGUI: Update progress of thumbnail generations on failure
Not doing it result in FileManager's progress bar being left as incomplete even if all jobs were finish.
This commit is contained in:
parent
ebb9c3a430
commit
b79cd5cf6e
1 changed files with 16 additions and 7 deletions
|
@ -699,12 +699,8 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
|
|||
auto const action = [path](auto&) {
|
||||
return render_thumbnail(path);
|
||||
};
|
||||
auto const on_complete = [path, weak_this](auto thumbnail) -> ErrorOr<void> {
|
||||
s_thumbnail_cache.with_locked([path, thumbnail](auto& cache) {
|
||||
cache.thumbnail_cache.set(path, thumbnail);
|
||||
cache.loading_thumbnails.remove(path);
|
||||
});
|
||||
|
||||
auto const update_progress = [weak_this](bool with_success) {
|
||||
if (auto strong_this = weak_this.strong_ref(); !strong_this.is_null()) {
|
||||
strong_this->m_thumbnail_progress++;
|
||||
if (strong_this->on_thumbnail_progress)
|
||||
|
@ -714,12 +710,23 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
|
|||
strong_this->m_thumbnail_progress_total = 0;
|
||||
}
|
||||
|
||||
strong_this->did_update(UpdateFlag::DontInvalidateIndices);
|
||||
if (with_success)
|
||||
strong_this->did_update(UpdateFlag::DontInvalidateIndices);
|
||||
}
|
||||
};
|
||||
|
||||
auto const on_complete = [path, update_progress](auto thumbnail) -> ErrorOr<void> {
|
||||
s_thumbnail_cache.with_locked([path, thumbnail](auto& cache) {
|
||||
cache.thumbnail_cache.set(path, thumbnail);
|
||||
cache.loading_thumbnails.remove(path);
|
||||
});
|
||||
|
||||
update_progress(true);
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
auto const on_error = [path](Error error) -> void {
|
||||
auto const on_error = [path, update_progress](Error error) -> void {
|
||||
// Note: We need to defer that to avoid the function removing its last reference
|
||||
// i.e. trying to destroy itself, which is prohibited.
|
||||
Core::EventLoop::current().deferred_invoke([&] {
|
||||
|
@ -731,6 +738,8 @@ bool FileSystemModel::fetch_thumbnail_for(Node const& node)
|
|||
cache.loading_thumbnails.remove(path);
|
||||
});
|
||||
});
|
||||
|
||||
update_progress(false);
|
||||
};
|
||||
|
||||
s_thumbnail_cache.with_locked([path, action, on_complete, on_error](auto& cache) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue