diff --git a/src/vapoursynth_common.cpp b/src/vapoursynth_common.cpp index 617849360..52614528c 100644 --- a/src/vapoursynth_common.cpp +++ b/src/vapoursynth_common.cpp @@ -23,15 +23,17 @@ #include int OpenScriptOrVideo(const VSSCRIPTAPI *api, VSScript *script, agi::fs::path const& filename, std::string default_script) { + int result; if (agi::fs::HasExtension(filename, "py") || agi::fs::HasExtension(filename, "vpy")) { - return api->evaluateFile(script, filename.string().c_str()); + result = api->evaluateFile(script, filename.string().c_str()); } else { std::string fname = filename.string(); boost::replace_all(fname, "\\", "\\\\"); boost::replace_all(fname, "'", "\\'"); std::string vscript = "filename = '" + fname + "'\n" + default_script; - return api->evaluateBuffer(script, vscript.c_str(), "aegisub"); + result = api->evaluateBuffer(script, vscript.c_str(), "aegisub"); } + return result; } #endif // WITH_VAPOURSYNTH diff --git a/src/vapoursynth_wrap.cpp b/src/vapoursynth_wrap.cpp index d0d0fbd8b..ac2b87dff 100644 --- a/src/vapoursynth_wrap.cpp +++ b/src/vapoursynth_wrap.cpp @@ -78,7 +78,12 @@ VapourSynthWrapper::VapourSynthWrapper() { if (!getVSScriptAPI) throw VapoursynthError("Failed to get address of getVSScriptAPI from " VSSCRIPT_SO); + // Python will set the program's locale to the user's default locale, which will break + // half of wxwidgets on some operating systems due to locale mismatches. There's not really anything + // we can do to fix it except for saving it and setting it back to its original value afterwards. + std::string oldlocale(setlocale(LC_ALL, NULL)); scriptapi = getVSScriptAPI(VSSCRIPT_API_VERSION); + setlocale(LC_ALL, oldlocale.c_str()); if (!scriptapi) throw VapoursynthError("Failed to get Vapoursynth ScriptAPI");