Recreate console window to print log messages if it was closed by the user

Regression introduced cc7da16691 when
the Console was converted to a non-modal window. If a script prints
something, the console is displayed, then the user can close the
console, and if the script tried to print something else the console
window wasn't displayed again until some other command was
executed (any command that called the Console::Console() constructor
which would create the ConsoleWindow again).

With this fix the console window is recreated/displayed again on the
screen.

This bug was well-known (but I think never reported yet) and probably
the possible source of the #3787 issue.
This commit is contained in:
David Capello 2023-04-05 18:26:15 -03:00
parent 264ee71b00
commit be11e3b324

View File

@ -248,13 +248,18 @@ void Console::printf(const char* format, ...)
std::string msg = base::string_vprintf(format, ap);
va_end(ap);
if (!m_withUI || !m_console) {
if (!m_withUI) {
fputs(msg.c_str(), stdout);
fflush(stdout);
return;
}
// Open the window
// Create the console window if it was closed/deleted by the user
if (!m_console) {
m_console = new ConsoleWindow;
}
// Open the window if it's hidden
if (!m_console->isVisible()) {
m_console->openWindow();
ui::Manager::getDefault()->invalidate();