mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibThreading+Everywhere: Support returning error from BackgroundAction
This patch allows returning an `Error` from the `on_complete` callback in `BackgroundAction`. It also adds a custom callback to manage errors returned during its execution.
This commit is contained in:
parent
664117564a
commit
2693745336
6 changed files with 38 additions and 21 deletions
|
@ -37,17 +37,19 @@ bool MonitorWidget::set_wallpaper(DeprecatedString path)
|
|||
return Gfx::Bitmap::try_load_from_file(path);
|
||||
},
|
||||
|
||||
[this, path](ErrorOr<NonnullRefPtr<Gfx::Bitmap>> bitmap_or_error) {
|
||||
[this, path](ErrorOr<NonnullRefPtr<Gfx::Bitmap>> bitmap_or_error) -> ErrorOr<void> {
|
||||
// If we've been requested to change while we were loading the bitmap, don't bother spending the cost to
|
||||
// move and render the now stale bitmap.
|
||||
if (is_different_to_current_wallpaper_path(path))
|
||||
return;
|
||||
return {};
|
||||
if (bitmap_or_error.is_error())
|
||||
m_wallpaper_bitmap = nullptr;
|
||||
else
|
||||
m_wallpaper_bitmap = bitmap_or_error.release_value();
|
||||
m_desktop_dirty = true;
|
||||
update();
|
||||
|
||||
return bitmap_or_error.is_error() ? bitmap_or_error.release_error() : ErrorOr<void> {};
|
||||
});
|
||||
|
||||
if (path.is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue