diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-03-18 16:05:46 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-19 01:26:37 +0000 |
commit | ebb9c3a4304e9860386189bc6ac43a11f84f6ec1 (patch) | |
tree | 69fd24eb4053b3413cf47cfa617d6672599bca0d /Userland/Libraries/LibThreading | |
parent | b0847596907e20a78819de88fefb010d98989f5c (diff) | |
download | serenity-ebb9c3a4304e9860386189bc6ac43a11f84f6ec1.zip |
LibThreading: Execute `on_error` on the original `EventLoop`
As the user might want to have interactions with LibGUI while handling
errors, this code should be executed in the original `EventLoop`.
Similarly to what is done with the error-free path.
Diffstat (limited to 'Userland/Libraries/LibThreading')
-rw-r--r-- | Userland/Libraries/LibThreading/BackgroundAction.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibThreading/BackgroundAction.h b/Userland/Libraries/LibThreading/BackgroundAction.h index 02aa6b3408..1d12128f8e 100644 --- a/Userland/Libraries/LibThreading/BackgroundAction.h +++ b/Userland/Libraries/LibThreading/BackgroundAction.h @@ -98,8 +98,12 @@ private: error = result.release_error(); m_promise->cancel(Error::from_errno(ECANCELED)); - if (m_on_error) - m_on_error(move(error)); + if (m_on_error) { + origin_event_loop->deferred_invoke([this, error = move(error)]() mutable { + m_on_error(move(error)); + }); + origin_event_loop->wake(); + } remove_from_parent(); } |