mirror of https://github.com/odrling/Aegisub
Pass exceptions in async workers back to the main thread
This commit is contained in:
parent
74e995b915
commit
eadf555da3
|
@ -91,7 +91,15 @@ void Init(std::function<void (Thunk)> invoke_main) {
|
|||
}
|
||||
|
||||
void Queue::Async(Thunk thunk) {
|
||||
DoInvoke(thunk);
|
||||
DoInvoke([=] {
|
||||
try {
|
||||
thunk();
|
||||
}
|
||||
catch (...) {
|
||||
auto e = std::current_exception();
|
||||
invoke_main([=] { std::rethrow_exception(e); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Queue::Sync(Thunk thunk) {
|
||||
|
|
|
@ -152,8 +152,13 @@ bool AegisubApp::OnInit() {
|
|||
wxTheApp->QueueEvent(evt);
|
||||
});
|
||||
|
||||
wxTheApp->Bind(EVT_CALL_THUNK, [](wxThreadEvent &evt) {
|
||||
wxTheApp->Bind(EVT_CALL_THUNK, [this](wxThreadEvent &evt) {
|
||||
try {
|
||||
evt.GetPayload<std::function<void()>>()();
|
||||
}
|
||||
catch (...) {
|
||||
OnExceptionInMainLoop();
|
||||
}
|
||||
});
|
||||
|
||||
config::path = new agi::Path;
|
||||
|
|
Loading…
Reference in New Issue