From aed23f47519cdaa0b660701e705e88561add498c Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 14 Sep 2018 20:38:27 -0300 Subject: [PATCH] lua: use the active EngineDelegate::onConsolePrint() in print() function This is needed to output print() messages in the DevConsoleView when it's open. --- src/app/script/engine.cpp | 10 +++++----- src/app/script/engine.h | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/script/engine.cpp b/src/app/script/engine.cpp index 69b690930..bd3255727 100644 --- a/src/app/script/engine.cpp +++ b/src/app/script/engine.cpp @@ -52,10 +52,8 @@ int print(lua_State* L) lua_pop(L, 1); // pop result } if (!output.empty()) { - std::printf("%s\n", output.c_str()); - std::fflush(stdout); - if (App::instance()->isGui()) - Console().printf("%s\n", output.c_str()); + App::instance()->scriptEngine() + ->consolePrint(output.c_str()); } return 0; } @@ -291,8 +289,10 @@ void Engine::onConsolePrint(const char* text) { if (m_delegate) m_delegate->onConsolePrint(text); - else + else { std::printf("%s\n", text); + std::fflush(stdout); + } } } // namespace script diff --git a/src/app/script/engine.h b/src/app/script/engine.h index 3898e6ffd..72182e5bb 100644 --- a/src/app/script/engine.h +++ b/src/app/script/engine.h @@ -58,6 +58,10 @@ namespace app { const std::string& filename = std::string()); bool evalFile(const std::string& filename); + void consolePrint(const char* text) { + onConsolePrint(text); + } + private: void onConsolePrint(const char* text);