diff --git a/src/colorer/parsers/TextParserImpl.cpp b/src/colorer/parsers/TextParserImpl.cpp index 7f9335a..8d51b17 100644 --- a/src/colorer/parsers/TextParserImpl.cpp +++ b/src/colorer/parsers/TextParserImpl.cpp @@ -521,8 +521,13 @@ bool TextParser::Impl::colorize(CRegExp* root_end_re, bool lowContentPriority) clearLine = current_parse_line; str = lineSource->getLine(current_parse_line); if (str == nullptr) { - throw Exception("null String passed into the parser: " + - UStr::to_unistr(current_parse_line)); + // LineSource can return null if the line is not available (e.g. editor shutdown). + // Stop parsing gracefully instead of throwing across threads. + str = nullptr; + clearLine = -1; + endLine = current_parse_line; + stackLevel--; + return true; } regionHandler->clearLine(current_parse_line, str); } diff --git a/src/colorer/strings/legacy/UnicodeString.cpp b/src/colorer/strings/legacy/UnicodeString.cpp index 227d4a3..bb3873c 100644 --- a/src/colorer/strings/legacy/UnicodeString.cpp +++ b/src/colorer/strings/legacy/UnicodeString.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "colorer/Exception.h" UnicodeString operator+(const UnicodeString& s1, const UnicodeString& s2) @@ -90,7 +91,8 @@ UnicodeString::UnicodeString(const UnicodeString& cstring, int32_t s, int32_t l) UnicodeString::UnicodeString(int no) { - CString dtext = CString(std::to_string(no).c_str()); + const std::string number_text = std::to_string(no); + CString dtext = CString(number_text.c_str()); construct(&dtext, 0, npos); }