From: <geo...@us...> - 2012-08-26 19:16:25
|
Revision: 5173 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5173&view=rev Author: geoffthemedio Date: 2012-08-26 19:16:18 +0000 (Sun, 26 Aug 2012) Log Message: ----------- Replaced some asserts with if checks in Font::HandleTag. I suspect there's an issue with rgba tags broken over lines, which has been leading to crashes mainly on Linux systems. Hopefully this will mean there is just some slightly glitchy colouration of text, rather than a crash, until a proper fix can be implemented. I don't notice any relevant rendering issues on Windows with (or without) this change. Modified Paths: -------------- trunk/FreeOrion/GG/src/Font.cpp Modified: trunk/FreeOrion/GG/src/Font.cpp =================================================================== --- trunk/FreeOrion/GG/src/Font.cpp 2012-08-26 05:44:03 UTC (rev 5172) +++ trunk/FreeOrion/GG/src/Font.cpp 2012-08-26 19:16:18 UTC (rev 5173) @@ -660,7 +660,7 @@ { double orig_color[4]; glGetDoublev(GL_CURRENT_COLOR, orig_color); - + if (!render_state.colors.empty()) glColor(render_state.colors.top()); @@ -1444,26 +1444,35 @@ { if (tag->tag_name == "i") { if (tag->close_tag) { - assert(render_state.use_italics); - --render_state.use_italics; + if (render_state.use_italics) { + --render_state.use_italics; + } } else { ++render_state.use_italics; } } else if (tag->tag_name == "u") { if (tag->close_tag) { - assert(render_state.draw_underline); - --render_state.draw_underline; + if (render_state.draw_underline) { + --render_state.draw_underline; + } } else { ++render_state.draw_underline; } } else if (tag->tag_name == "rgba") { if (tag->close_tag) { - assert(!render_state.colors.empty()); - render_state.colors.pop(); - if (render_state.colors.empty()) - glColor4dv(orig_color); - else - glColor(render_state.colors.top()); + // commenting out this assert because, I think, if a multi-word + // substring is wrapped in rgba tags and then is split over a line- + // break, the render state (or at least the colour portion thereof, + // I think...) is reset, but the closing rgba tag will still be + // present on the next line, leading to a crash due to a closing + // rgba tag when the render state for the line has no colour + if (!render_state.colors.empty()) { + render_state.colors.pop(); + if (render_state.colors.empty()) + glColor4dv(orig_color); + else + glColor(render_state.colors.top()); + } } else { using boost::lexical_cast; bool well_formed_tag = true; |