[textlayout] move addition of '\n' for the last line into LineBreakText
authorJonathan Marshall <jmarshall@never.you.mind>
Sat, 11 May 2013 00:16:47 +0000 (12:16 +1200)
committerJonathan Marshall <jmarshall@never.you.mind>
Sat, 11 May 2013 06:13:24 +0000 (18:13 +1200)
xbmc/guilib/GUITextLayout.cpp

index 33bf1b7..9435abe 100644 (file)
@@ -232,9 +232,6 @@ bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bo
   // parse the text into our string objects
   ParseText(text, parsedText);
 
-  // add \n to the end of the string
-  parsedText.push_back(L'\n');
-
   // if we need to wrap the text, then do so
   if (m_wrap && maxWidth > 0)
     WrapText(parsedText, maxWidth);
@@ -559,6 +556,12 @@ void CGUITextLayout::LineBreakText(const vecText &text, vector<CGUIString> &line
     }
     pos++;
   }
+  // handle the last line if non-empty
+  if (lineStart < text.end() && (nMaxLines <= 0 || lines.size() < (size_t)nMaxLines))
+  {
+    CGUIString string(lineStart, text.end(), true);
+    lines.push_back(string);
+  }
 }
 
 void CGUITextLayout::GetTextExtent(float &width, float &height) const