X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fconsole.cpp;h=1d27bc87b201c16cf04f58dc59fca4b8ffcd7f55;hb=219ec61655edf6785ef483905b162604a215f5f4;hp=9f1726764a00da76b72cee87ecbe799c191de419;hpb=4e70d578de5d05a2bbc945f1d3853db758161f8f;p=supertux.git diff --git a/src/supertux/console.cpp b/src/supertux/console.cpp index 9f1726764..1d27bc87b 100644 --- a/src/supertux/console.cpp +++ b/src/supertux/console.cpp @@ -123,6 +123,16 @@ Console::~Console() void Console::on_buffer_change(int line_count) { + if (!m_font) + { + // FIXME: This is an ugly workaround for a crash at startup. + // Console::current() becomes valid before the Console constructor + // is finished and loading Surfaces and Fonts wants to write text + // to the Console, with Fonts that aren't yet loaded, thus + // crashing + return; + } + // increase console height if necessary if (m_stayOpen > 0 && m_height < 64) { @@ -247,11 +257,11 @@ void Console::show_history(int offset_) { while ((offset_ > 0) && (m_history_position != m_history.end())) { - m_history_position++; + ++m_history_position; offset_--; } while ((offset_ < 0) && (m_history_position != m_history.begin())) { - m_history_position--; + --m_history_position; offset_++; } if (m_history_position == m_history.end()) { @@ -414,10 +424,9 @@ Console::parse(std::string s) // split line into list of args std::vector args; - size_t start = 0; size_t end = 0; while (1) { - start = s.find_first_not_of(" ,", end); + size_t start = s.find_first_not_of(" ,", end); end = s.find_first_of(" ,", start); if (start == s.npos) break; args.push_back(s.substr(start, end-start)); @@ -551,7 +560,7 @@ Console::draw(DrawingContext& context) } int skipLines = -m_offset; - for (std::list::iterator i = m_buffer.m_lines.begin(); i != m_buffer.m_lines.end(); i++) + for (std::list::iterator i = m_buffer.m_lines.begin(); i != m_buffer.m_lines.end(); ++i) { if (skipLines-- > 0) continue; lineNo++;