From 0bb02fb34fc89a3b21354d45da6ed4c7bba69337 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Mon, 20 Oct 2014 10:41:01 +0800 Subject: [PATCH] Fix Label: endless loop if not using system font, and constrained length is less than one character width --- cocos/2d/CCLabelTextFormatter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 56bc1d55fe..4532ab0e2c 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -151,16 +151,16 @@ bool LabelTextFormatter::multilineText(Label *theLabel) else { StringUtils::trimUTF16Vector(last_word); - if (isStartOfLine) + //issue #8492:endless loop if not using system font, and constrained length is less than one character width + if (isStartOfLine && last_word.size() == 0) last_word.push_back(character); - - last_word.push_back('\n'); - - multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); - last_word.clear(); - if (!isStartOfLine) + else --j; + last_word.push_back('\n'); + multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end()); + last_word.clear(); + isStartOfWord = false; isStartOfLine = false; startOfWord = -1;