[Scummvm-git-logs] scummvm master -> ff0abf2b69b2b56dfdd075399a23ebc6d90686f0
sev-
noreply at scummvm.org
Wed Nov 15 23:23:18 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ff0abf2b69 GRAPHICS: MACGUI: Fix crashes when dealing with empty MacTexts
Commit: ff0abf2b69b2b56dfdd075399a23ebc6d90686f0
https://github.com/scummvm/scummvm/commit/ff0abf2b69b2b56dfdd075399a23ebc6d90686f0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-11-16T00:23:09+01:00
Commit Message:
GRAPHICS: MACGUI: Fix crashes when dealing with empty MacTexts
Changed paths:
graphics/macgui/mactext-canvas.cpp
graphics/macgui/mactext.cpp
diff --git a/graphics/macgui/mactext-canvas.cpp b/graphics/macgui/mactext-canvas.cpp
index 52f5c290ba5..f41bb98e2e9 100644
--- a/graphics/macgui/mactext-canvas.cpp
+++ b/graphics/macgui/mactext-canvas.cpp
@@ -219,6 +219,9 @@ const Common::U32String::value_type *MacTextCanvas::splitString(const Common::U3
if (curLine == -1 || curLine >= (int)_text.size())
curLine = _text.size() - 1;
+ if (_text[curLine].chunks.empty())
+ _text[curLine].chunks.push_back(_defaultFormatting);
+
int curChunk = _text[curLine].chunks.size() - 1;
MacFontRun chunk = _text[curLine].chunks[curChunk];
int indentSize = 0;
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index f3a5dd575fd..b5d8afaf881 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -98,7 +98,7 @@ uint MacTextLine::getChunkNum(int *col) {
}
}
- if (i == chunks.size()) {
+ if (i && i == chunks.size()) {
i--; // touch the last chunk
pos = chunks[i].text.size();
}
@@ -1756,7 +1756,7 @@ void MacText::setText(const Common::U32String &str) {
//////////////////
// Text editing
void MacText::insertChar(byte c, int *row, int *col) {
- if (_canvas._text.empty()) {
+ if (_canvas._text.empty() || _canvas._text[*row].chunks.empty()) {
appendTextDefault(Common::String(c));
(*col)++;
More information about the Scummvm-git-logs
mailing list