mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
lua: Fix crash on program exit if some metatable.__gc calls print()
This commit is contained in:
parent
ff2af4f3e8
commit
45fc74f596
@ -73,8 +73,13 @@ int print(lua_State* L)
|
|||||||
lua_pop(L, 1); // pop result
|
lua_pop(L, 1); // pop result
|
||||||
}
|
}
|
||||||
if (!output.empty()) {
|
if (!output.empty()) {
|
||||||
App::instance()->scriptEngine()
|
auto app = App::instance();
|
||||||
->consolePrint(output.c_str());
|
if (app && app->scriptEngine())
|
||||||
|
app->scriptEngine()->consolePrint(output.c_str());
|
||||||
|
else {
|
||||||
|
std::printf("%s\n", output.c_str());
|
||||||
|
std::fflush(stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -444,6 +449,9 @@ bool Engine::evalFile(const std::string& filename,
|
|||||||
|
|
||||||
void Engine::onConsolePrint(const char* text)
|
void Engine::onConsolePrint(const char* text)
|
||||||
{
|
{
|
||||||
|
if (!text)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_delegate)
|
if (m_delegate)
|
||||||
m_delegate->onConsolePrint(text);
|
m_delegate->onConsolePrint(text);
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user