From 303b079257a20fcbd00fd533bdbc964ace978149 Mon Sep 17 00:00:00 2001 From: pajlada Date: Thu, 11 Feb 2021 12:52:50 +0100 Subject: [PATCH] Remove bad asserts from IRC text wrapping code (#2446) --- src/messages/MessageElement.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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()) {