mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 17:29:11 +00:00
GRAPHICS: MACGUI: Stop MacTextCanvas::chopChunk from removing last chunk
There needs to be at least one chunk per line of text, or else many basic text operations will cause a crash.
This commit is contained in:
parent
b4bdc229db
commit
95b47042f0
@ -60,7 +60,7 @@ void MacTextCanvas::chopChunk(const Common::U32String &str, int *curLinePtr, int
|
||||
// Check if there is nothing to add, then remove the last chunk
|
||||
// This happens when the previous run is finished only with
|
||||
// empty formatting, or when we were adding text for the first time
|
||||
if (chunk->text.empty() && str.empty()) {
|
||||
if (chunk->text.empty() && str.empty() && (_text[curLine].chunks.size() > 1)) {
|
||||
D(9, "** chopChunk, replaced formatting, line %d", curLine);
|
||||
|
||||
_text[curLine].chunks.pop_back();
|
||||
@ -1109,7 +1109,7 @@ void MacTextCanvas::reshuffleParagraph(int *row, int *col, MacFontRun &defaultFo
|
||||
bool paragraphEnd = _text[end].paragraphEnd;
|
||||
|
||||
#if DEBUG
|
||||
D(9, "MacTextCanvas::reshuffleParagraph: ppos: %d", ppos);
|
||||
D(9, "MacTextCanvas::reshuffleParagraph: ppos: %d, start: %d, end: %d", ppos, start, end);
|
||||
debugPrint("MacTextCanvas::reshuffleParagraph(1)");
|
||||
#endif
|
||||
|
||||
@ -1168,8 +1168,14 @@ void MacTextCanvas::reshuffleParagraph(int *row, int *col, MacFontRun &defaultFo
|
||||
|
||||
#if DEBUG
|
||||
debugPrint("MacTextCanvas::reshuffleParagraph(3)");
|
||||
D(9, "Chunks: ");
|
||||
for (auto &ch : _text[curLine].chunks)
|
||||
ch.debugPrint();
|
||||
|
||||
D(9, "");
|
||||
#endif
|
||||
|
||||
|
||||
// Restore the paragraph marker
|
||||
_text[curLine].paragraphEnd = paragraphEnd;
|
||||
|
||||
|
@ -1850,6 +1850,13 @@ void MacText::deletePreviousCharInternal(int *row, int *col) {
|
||||
*col = _canvas.getLineCharWidth(*row - 1);
|
||||
(*row)--;
|
||||
|
||||
#if DEBUG
|
||||
D(9, "MacText::deletePreviousCharInternal: Chunks: ");
|
||||
for (auto &ch : _canvas._text[*row].chunks)
|
||||
ch.debugPrint();
|
||||
|
||||
D(9, "");
|
||||
#endif
|
||||
// formatting matches, glue texts as normal
|
||||
if (_canvas._text[*row].lastChunk().equals(_canvas._text[*row + 1].firstChunk())) {
|
||||
_canvas._text[*row].lastChunk().text += _canvas._text[*row + 1].firstChunk().text;
|
||||
@ -1911,6 +1918,15 @@ void MacText::addNewLine(int *row, int *col) {
|
||||
MacTextLine *line = &_canvas._text[*row];
|
||||
int pos = *col;
|
||||
uint ch = line->getChunkNum(&pos);
|
||||
|
||||
#if DEBUG
|
||||
D(9, "MacText::addNewLine: Chunks: ");
|
||||
for (auto &c : line->chunks)
|
||||
c.debugPrint();
|
||||
|
||||
D(9, "");
|
||||
#endif
|
||||
|
||||
MacFontRun newchunk = line->chunks[ch];
|
||||
MacTextLine newline;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user