diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index f6aae1fad..211404a42 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -611,7 +611,7 @@ void IrcTextElement::addToContainer(MessageLayoutContainer &container, } } - // we done goofed, we need to wrap the text + // The word does not fit on a new line, we need to wrap it QString text = word.text; std::vector segments = word.segments; int textLength = text.length(); @@ -625,6 +625,7 @@ void IrcTextElement::addToContainer(MessageLayoutContainer &container, { if (!container.canAddElements()) { + // The container does not allow any more elements to be added, stop here break; } @@ -638,11 +639,10 @@ void IrcTextElement::addToContainer(MessageLayoutContainer &container, { std::vector pieceSegments; int charactersLeft = i - wordStart; - assert(charactersLeft > 0); + for (auto segmentIt = segments.begin(); segmentIt != segments.end();) { - assert(charactersLeft > 0); auto &segment = *segmentIt; if (charactersLeft >= segment.text.length()) {