From 4e2053fb56095598fa8a9f29cc0fca692e0238a2 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 19 Mar 2024 20:20:11 +0800 Subject: [PATCH] fix: crash when set breakpoints in an empty C/C++ file --- NEWS.md | 1 + RedPandaIDE/translations/RedPandaIDE_pt_BR.ts | 18 +++++++++--------- RedPandaIDE/translations/RedPandaIDE_zh_CN.ts | 16 ++++++++-------- RedPandaIDE/translations/RedPandaIDE_zh_TW.ts | 18 +++++++++--------- libs/qsynedit/qsynedit/document.cpp | 4 ++++ 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/NEWS.md b/NEWS.md index cfa125b6..029c35d8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -57,6 +57,7 @@ Red Panda C++ Version 2.27 - change: When debugging, don't auto set focus to the editor. - enhancement: Folding button scales with editor font. - fix: Should show header completion popup in #include line comments. + - fix: Custom compile options not correctly parsed. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index ec75a814..617ea439 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -555,7 +555,7 @@ [Nota] - + The compiler process for '%1' failed to start. Falha ao iniciar a compilação para '%1'. @@ -590,7 +590,7 @@ - + - Command: %1 @@ -1382,7 +1382,7 @@ - + @@ -1390,7 +1390,7 @@ Erro - + Save As Salvar como @@ -1400,7 +1400,7 @@ Arquivo %1 já aberto! - + The text to be copied exceeds count limit! O texto a ser copiado excede o limite do contador! @@ -1425,7 +1425,7 @@ Imprimir documento - + Ctrl+click for more info @@ -1457,13 +1457,13 @@ Apenas leitura - + Error Load File Erro ao carregar arquivo - + hex: %1 @@ -1870,7 +1870,7 @@ - + Show only monospaced fonts Mostrar apenas fontes com espaçamento único diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index b8046486..f91cbdcc 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -692,7 +692,7 @@ p, li { white-space: pre-wrap; } 警告: - + Can't open file "%1" for write! 无法写入文件“%1”。 @@ -1596,7 +1596,7 @@ p, li { white-space: pre-wrap; } - + @@ -1608,7 +1608,7 @@ p, li { white-space: pre-wrap; } 无法写入文件"%1" - + Error Load File 载入文件错误 @@ -1648,7 +1648,7 @@ p, li { white-space: pre-wrap; } 文件%1已经被打开! - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! @@ -1683,7 +1683,7 @@ p, li { white-space: pre-wrap; } 打印文档 - + Ctrl+click for more info @@ -2120,7 +2120,7 @@ p, li { white-space: pre-wrap; } 选择字体 - + Show only monospaced fonts 只显示等宽字体 @@ -6598,7 +6598,7 @@ p, li { white-space: pre-wrap; } Line: %1/%2 Col: %3 Sel: %4 - + 行: %1/%2 列: %3 选中: %4 @@ -6608,7 +6608,7 @@ p, li { white-space: pre-wrap; } Line: %1/%2 Char: %3/%4 Sel: %5 - + 行: %1/%2 字符: %3/%4 选中: %5 diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index 5c722779..d6841231 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -456,7 +456,7 @@ - + The compiler process for '%1' failed to start. @@ -491,7 +491,7 @@ - + - Command: %1 @@ -1227,7 +1227,7 @@ - + @@ -1235,7 +1235,7 @@ - + Save As @@ -1245,7 +1245,7 @@ - + The text to be copied exceeds count limit! @@ -1270,7 +1270,7 @@ - + Ctrl+click for more info @@ -1302,13 +1302,13 @@ - + Error Load File - + hex: %1 @@ -1711,7 +1711,7 @@ - + Show only monospaced fonts diff --git a/libs/qsynedit/qsynedit/document.cpp b/libs/qsynedit/qsynedit/document.cpp index 0df671a5..e1409a79 100644 --- a/libs/qsynedit/qsynedit/document.cpp +++ b/libs/qsynedit/qsynedit/document.cpp @@ -947,12 +947,16 @@ int Document::glyphLength(int line, int glyphIdx) int Document::glyphStartPostion(int line, int glyphIdx) { QMutexLocker locker(&mMutex); + if (line<0 || line>=count()) + return 0; return mLines[line]->glyphStartPosition(glyphIdx); } int Document::glyphWidth(int line, int glyphIdx) { QMutexLocker locker(&mMutex); + if (line<0 || line>=count()) + return 0; return mLines[line]->glyphWidth(glyphIdx); }