From 51cd2678aeb094b1b50d417b8d189b0331b4ab56 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sun, 21 Sep 2014 22:25:54 +0200 Subject: [PATCH] Book formatter: Fix last block of text not displaying --- apps/openmw/mwgui/formatting.cpp | 18 +++++++++++------- apps/openmw/mwgui/formatting.hpp | 1 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index a7aee1bc9..c8b6f3983 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -50,8 +50,12 @@ namespace MWGui while (1) { ++mIndex; + if (mIndex >= mText.size()) + { + flushBuffer(); return Event_EOF; + } char ch = mText[mIndex]; if (ch == '<') @@ -102,11 +106,7 @@ namespace MWGui } } - if (mIndex == mText.size() - 1) - { - flushBuffer(); - return Event_LastText; - } + } } @@ -133,7 +133,7 @@ namespace MWGui while (!tag.empty()) { - int sepPos = tag.find('='); + size_t sepPos = tag.find('='); if (sepPos == std::string::npos) return; @@ -188,8 +188,9 @@ namespace MWGui BookTextParser parser(markup); BookTextParser::Events event; - while ((event = parser.next()) != BookTextParser::Event_EOF) + for (;;) { + event = parser.next(); if (event == BookTextParser::Event_BrTag || event == BookTextParser::Event_PTag) continue; @@ -204,6 +205,9 @@ namespace MWGui elem.paginate(); } + if (event == BookTextParser::Event_EOF) + break; + switch (event) { case BookTextParser::Event_ImgTag: diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 545c1f31d..71e398f7f 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -32,7 +32,6 @@ namespace MWGui { Event_None = -2, Event_EOF = -1, - Event_LastText = 0, Event_BrTag, Event_PTag, Event_ImgTag,