Update translations. Code dedup and cleanup

This commit is contained in:
Lam Wei Lun
2026-09-11 13:05:39 +08:00
parent 42bee12481
commit 7c2991d00c
47 changed files with 2559 additions and 1180 deletions
+17 -10
View File
@@ -543,15 +543,16 @@ bool install_local_plugin_package(const boost::filesystem::path& package_file, w
});
timer->Start(100);
bool finished = false;
wxEventLoop loop;
auto on_finish = [&finished, &loop]() {
finished = true;
if (loop.IsRunning())
loop.Exit();
// finished/loop live on the heap: the worker's completion callback is posted to the UI loop
// and can still fire after this stack frame is gone, so it must not reference locals.
struct WaitState
{
bool finished = false;
wxEventLoop loop;
};
auto wait = std::make_shared<WaitState>();
std::thread([state, package_file, on_finish]() mutable {
std::thread([state, package_file, wait]() mutable {
std::string error;
bool ok = false;
try {
@@ -570,11 +571,17 @@ bool install_local_plugin_package(const boost::filesystem::path& package_file, w
state->ok = ok;
state->error = std::move(error);
}
wxTheApp->CallAfter(on_finish);
if (!wxTheApp)
return;
wxTheApp->CallAfter([wait]() {
wait->finished = true;
if (wait->loop.IsRunning())
wait->loop.Exit();
});
}).detach();
if (!finished)
loop.Run();
if (!wait->finished)
wait->loop.Run();
timer->Stop();
delete timer;