diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index 3cff8d280..30f7e5376 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -722,28 +722,25 @@ namespace Automation4 { return lua_error(L); } - static void lua_threaded_call(ProgressSink *ps, lua_State *L, int nargs, int nresults, bool can_open_config, bool *failed) - { - LuaProgressSink lps(L, ps, can_open_config); - - if (lua_pcall(L, nargs, nresults, 0)) { - if (!lua_isnil(L, -1)) { - // if the call failed, log the error here - ps->Log("\n\nLua reported a runtime error:\n"); - ps->Log(lua_tostring(L, -1)); - } - lua_pop(L, 1); - *failed = true; - } - - lua_gc(L, LUA_GCCOLLECT, 0); - } - void LuaThreadedCall(lua_State *L, int nargs, int nresults, wxString const& title, wxWindow *parent, bool can_open_config) { bool failed = false; BackgroundScriptRunner bsr(parent, title); - bsr.Run([&](ProgressSink *ps) { lua_threaded_call(ps, L, nargs, nresults, can_open_config, &failed); }); + bsr.Run([&](ProgressSink *ps) { + LuaProgressSink lps(L, ps, can_open_config); + + if (lua_pcall(L, nargs, nresults, 0)) { + if (!lua_isnil(L, -1)) { + // if the call failed, log the error here + ps->Log("\n\nLua reported a runtime error:\n"); + ps->Log(lua_tostring(L, -1)); + } + lua_pop(L, 1); + failed = true; + } + + lua_gc(L, LUA_GCCOLLECT, 0); + }); if (failed) throw agi::UserCancelException("Script threw an error"); } diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index 5cb6f20b6..af5ae0ce2 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -51,10 +51,6 @@ #include #include -static void save_skip_comments(wxCommandEvent &evt) { - OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt()); -} - DialogSpellChecker::DialogSpellChecker(agi::Context *context) : wxDialog(context->parent, -1, _("Spell Checker")) , context(context) @@ -129,7 +125,8 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) skip_comments = new wxCheckBox(this, -1, _("&Skip Comments")); actions_sizer->Add(skip_comments, button_flags); skip_comments->SetValue(OPT_GET("Tool/Spell Checker/Skip Comments")->GetBool()); - skip_comments->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, save_skip_comments); + skip_comments->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, + [](wxCommandEvent &evt) { OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt()); }); wxButton *button; diff --git a/aegisub/src/subtitles_provider_libass.cpp b/aegisub/src/subtitles_provider_libass.cpp index 965ada76f..7c0852c49 100644 --- a/aegisub/src/subtitles_provider_libass.cpp +++ b/aegisub/src/subtitles_provider_libass.cpp @@ -114,21 +114,17 @@ public: } }; -static void do_wait(agi::ProgressSink *ps, FontConfigCacheThread const * const * const cache_worker) { - ps->SetIndeterminate(); - while (*cache_worker && !ps->IsCancelled()) - wxMilliSleep(100); -} - static void wait_for_cache_thread(FontConfigCacheThread const * const * const cache_worker) { if (!*cache_worker) return; DialogProgress progress(wxGetApp().frame, "Updating font index", "This may take several minutes"); - progress.Run(std::bind(do_wait, std::placeholders::_1, cache_worker)); + progress.Run([=](agi::ProgressSink *ps) { + ps->SetIndeterminate(); + while (*cache_worker && !ps->IsCancelled()) + wxMilliSleep(100); + }); } -/// @brief Constructor -/// LibassSubtitlesProvider::LibassSubtitlesProvider(std::string) { wait_for_cache_thread(&cache_worker); diff --git a/aegisub/src/threaded_frame_source.cpp b/aegisub/src/threaded_frame_source.cpp index 674cb4fb4..cce3fc9a5 100644 --- a/aegisub/src/threaded_frame_source.cpp +++ b/aegisub/src/threaded_frame_source.cpp @@ -61,13 +61,12 @@ struct invisible_line : public std::unary_function { } }; -static void delete_frame(AegiVideoFrame *frame) { - frame->Clear(); - delete frame; -} - std::shared_ptr ThreadedFrameSource::ProcFrame(int frameNum, double time, bool raw) { - std::shared_ptr frame(new AegiVideoFrame, delete_frame); + std::shared_ptr frame(new AegiVideoFrame, [](AegiVideoFrame *frame) { + frame->Clear(); + delete frame; + }); + { wxMutexLocker locker(providerMutex); try {