diff --git a/src/app/console.cpp b/src/app/console.cpp index aba8b47d0..2da2c8ef4 100644 --- a/src/app/console.cpp +++ b/src/app/console.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2016 David Capello +// Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -34,6 +34,7 @@ static Widget* wid_cancel = NULL; static int console_counter = 0; static bool console_locked; static bool want_close_flag = false; +static bool has_text = false; Console::Console(Context* ctx) : m_withUI(false) @@ -42,13 +43,17 @@ Console::Console(Context* ctx) m_withUI = (ctx->isUIAvailable()); else m_withUI = - (App::instance()->isGui() && + (App::instance() && + App::instance()->isGui() && Manager::getDefault() && Manager::getDefault()->getDisplay()); if (!m_withUI) return; + if (console_counter == 0) + has_text = false; + console_counter++; if (wid_console || console_counter > 1) return; @@ -104,8 +109,15 @@ Console::~Console() } } +bool Console::hasText() const +{ + return has_text; +} + void Console::printf(const char* format, ...) { + has_text = true; + std::va_list ap; va_start(ap, format); std::string msg = base::string_vprintf(format, ap); diff --git a/src/app/console.h b/src/app/console.h index 8a6afc850..1aa30d149 100644 --- a/src/app/console.h +++ b/src/app/console.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2015 David Capello +// Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of // the End-User License Agreement for Aseprite. @@ -18,6 +18,8 @@ namespace app { Console(Context* ctx = nullptr); ~Console(); + bool hasText() const; + void printf(const char *format, ...); static void showException(const std::exception& e);