fix: crash when set breakpoints in an empty C/C++ file

This commit is contained in:
Roy Qu 2024-03-19 20:20:11 +08:00
parent 5be546e97f
commit 4e2053fb56
5 changed files with 31 additions and 26 deletions

View File

@ -57,6 +57,7 @@ Red Panda C++ Version 2.27
- change: When debugging, don't auto set focus to the editor. - change: When debugging, don't auto set focus to the editor.
- enhancement: Folding button scales with editor font. - enhancement: Folding button scales with editor font.
- fix: Should show header completion popup in #include line comments. - fix: Should show header completion popup in #include line comments.
- fix: Custom compile options not correctly parsed.
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -555,7 +555,7 @@
<translation>[Nota] </translation> <translation>[Nota] </translation>
</message> </message>
<message> <message>
<location line="+547"/> <location line="+548"/>
<source>The compiler process for &apos;%1&apos; failed to start.</source> <source>The compiler process for &apos;%1&apos; failed to start.</source>
<translation>Falha ao iniciar a compilação para &apos;%1&apos;.</translation> <translation>Falha ao iniciar a compilação para &apos;%1&apos;.</translation>
</message> </message>
@ -590,7 +590,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-632"/> <location line="-633"/>
<source> - Command: %1</source> <source> - Command: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1382,7 +1382,7 @@
<location filename="../editor.cpp" line="+372"/> <location filename="../editor.cpp" line="+372"/>
<location line="+70"/> <location line="+70"/>
<location line="+29"/> <location line="+29"/>
<location line="+1086"/> <location line="+1092"/>
<location line="+5"/> <location line="+5"/>
<location line="+21"/> <location line="+21"/>
<location line="+5"/> <location line="+5"/>
@ -1390,7 +1390,7 @@
<translation>Erro</translation> <translation>Erro</translation>
</message> </message>
<message> <message>
<location line="-1180"/> <location line="-1186"/>
<source>Save As</source> <source>Save As</source>
<translation>Salvar como</translation> <translation>Salvar como</translation>
</message> </message>
@ -1400,7 +1400,7 @@
<translation>Arquivo %1 aberto!</translation> <translation>Arquivo %1 aberto!</translation>
</message> </message>
<message> <message>
<location line="+1115"/> <location line="+1121"/>
<source>The text to be copied exceeds count limit!</source> <source>The text to be copied exceeds count limit!</source>
<translation>O texto a ser copiado excede o limite do contador!</translation> <translation>O texto a ser copiado excede o limite do contador!</translation>
</message> </message>
@ -1425,7 +1425,7 @@
<translation>Imprimir documento</translation> <translation>Imprimir documento</translation>
</message> </message>
<message> <message>
<location line="+778"/> <location line="+788"/>
<location line="+25"/> <location line="+25"/>
<location line="+47"/> <location line="+47"/>
<source>Ctrl+click for more info</source> <source>Ctrl+click for more info</source>
@ -1457,13 +1457,13 @@
<translation>Apenas leitura</translation> <translation>Apenas leitura</translation>
</message> </message>
<message> <message>
<location line="-5331"/> <location line="-5347"/>
<location line="+434"/> <location line="+434"/>
<source>Error Load File</source> <source>Error Load File</source>
<translation type="unfinished">Erro ao carregar arquivo</translation> <translation type="unfinished">Erro ao carregar arquivo</translation>
</message> </message>
<message> <message>
<location line="+1576"/> <location line="+1582"/>
<source>hex: %1</source> <source>hex: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1870,7 +1870,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+9"/> <location line="+22"/>
<source>Show only monospaced fonts</source> <source>Show only monospaced fonts</source>
<translation>Mostrar apenas fontes com espaçamento único</translation> <translation>Mostrar apenas fontes com espaçamento único</translation>
</message> </message>

View File

@ -692,7 +692,7 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location line="+519"/> <location line="+520"/>
<source>Can&apos;t open file &quot;%1&quot; for write!</source> <source>Can&apos;t open file &quot;%1&quot; for write!</source>
<translation>%1</translation> <translation>%1</translation>
</message> </message>
@ -1596,7 +1596,7 @@ p, li { white-space: pre-wrap; }
<location filename="../editor.cpp" line="+372"/> <location filename="../editor.cpp" line="+372"/>
<location line="+70"/> <location line="+70"/>
<location line="+29"/> <location line="+29"/>
<location line="+1086"/> <location line="+1092"/>
<location line="+5"/> <location line="+5"/>
<location line="+21"/> <location line="+21"/>
<location line="+5"/> <location line="+5"/>
@ -1608,7 +1608,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished">&quot;%1&quot;</translation> <translation type="vanished">&quot;%1&quot;</translation>
</message> </message>
<message> <message>
<location line="-1473"/> <location line="-1479"/>
<location line="+434"/> <location line="+434"/>
<source>Error Load File</source> <source>Error Load File</source>
<translation></translation> <translation></translation>
@ -1648,7 +1648,7 @@ p, li { white-space: pre-wrap; }
<translation>%1</translation> <translation>%1</translation>
</message> </message>
<message> <message>
<location line="+1115"/> <location line="+1121"/>
<source>The text to be copied exceeds count limit!</source> <source>The text to be copied exceeds count limit!</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1683,7 +1683,7 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location line="+778"/> <location line="+788"/>
<location line="+25"/> <location line="+25"/>
<location line="+47"/> <location line="+47"/>
<source>Ctrl+click for more info</source> <source>Ctrl+click for more info</source>
@ -2120,7 +2120,7 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location line="+9"/> <location line="+22"/>
<source>Show only monospaced fonts</source> <source>Show only monospaced fonts</source>
<translation></translation> <translation></translation>
</message> </message>
@ -6598,7 +6598,7 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="+265"/> <location line="+265"/>
<source>Line: %1/%2 Col: %3 Sel: %4</source> <source>Line: %1/%2 Col: %3 Sel: %4</source>
<translation type="unfinished"></translation> <translation>: %1/%2 : %3 : %4</translation>
</message> </message>
<message> <message>
<location line="+6"/> <location line="+6"/>
@ -6608,7 +6608,7 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="+7"/> <location line="+7"/>
<source>Line: %1/%2 Char: %3/%4 Sel: %5</source> <source>Line: %1/%2 Char: %3/%4 Sel: %5</source>
<translation type="unfinished"></translation> <translation>: %1/%2 : %3/%4 : %5</translation>
</message> </message>
<message> <message>
<location line="+1326"/> <location line="+1326"/>

View File

@ -456,7 +456,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+547"/> <location line="+548"/>
<source>The compiler process for &apos;%1&apos; failed to start.</source> <source>The compiler process for &apos;%1&apos; failed to start.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -491,7 +491,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-632"/> <location line="-633"/>
<source> - Command: %1</source> <source> - Command: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1227,7 +1227,7 @@
<location filename="../editor.cpp" line="+372"/> <location filename="../editor.cpp" line="+372"/>
<location line="+70"/> <location line="+70"/>
<location line="+29"/> <location line="+29"/>
<location line="+1086"/> <location line="+1092"/>
<location line="+5"/> <location line="+5"/>
<location line="+21"/> <location line="+21"/>
<location line="+5"/> <location line="+5"/>
@ -1235,7 +1235,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-1180"/> <location line="-1186"/>
<source>Save As</source> <source>Save As</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1245,7 +1245,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+1115"/> <location line="+1121"/>
<source>The text to be copied exceeds count limit!</source> <source>The text to be copied exceeds count limit!</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1270,7 +1270,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+778"/> <location line="+788"/>
<location line="+25"/> <location line="+25"/>
<location line="+47"/> <location line="+47"/>
<source>Ctrl+click for more info</source> <source>Ctrl+click for more info</source>
@ -1302,13 +1302,13 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-5331"/> <location line="-5347"/>
<location line="+434"/> <location line="+434"/>
<source>Error Load File</source> <source>Error Load File</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+1576"/> <location line="+1582"/>
<source>hex: %1</source> <source>hex: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1711,7 +1711,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+9"/> <location line="+22"/>
<source>Show only monospaced fonts</source> <source>Show only monospaced fonts</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -947,12 +947,16 @@ int Document::glyphLength(int line, int glyphIdx)
int Document::glyphStartPostion(int line, int glyphIdx) int Document::glyphStartPostion(int line, int glyphIdx)
{ {
QMutexLocker locker(&mMutex); QMutexLocker locker(&mMutex);
if (line<0 || line>=count())
return 0;
return mLines[line]->glyphStartPosition(glyphIdx); return mLines[line]->glyphStartPosition(glyphIdx);
} }
int Document::glyphWidth(int line, int glyphIdx) int Document::glyphWidth(int line, int glyphIdx)
{ {
QMutexLocker locker(&mMutex); QMutexLocker locker(&mMutex);
if (line<0 || line>=count())
return 0;
return mLines[line]->glyphWidth(glyphIdx); return mLines[line]->glyphWidth(glyphIdx);
} }