- fix: Crash if close file while auto syntax checking.

This commit is contained in:
Roy Qu 2023-08-12 13:51:35 +08:00
parent 496421e97d
commit f462d6708d
4 changed files with 14 additions and 9 deletions

View File

@ -26,6 +26,7 @@ Red Panda C++ Version 2.24
- fix: When opening multiple files, only the active file should be parsed. - fix: When opening multiple files, only the active file should be parsed.
- fix: Wrong compiler settings if xcode is not installed in mac os. - fix: Wrong compiler settings if xcode is not installed in mac os.
- enhancement: Name for new files will not be different from files openned. - enhancement: Name for new files will not be different from files openned.
- fix: Crash if close file while auto syntax checking.
Red Panda C++ Version 2.23 Red Panda C++ Version 2.23

View File

@ -323,7 +323,7 @@ QString Compiler::getCharsetArgument(const QByteArray& encoding,FileType fileTyp
// test if force utf8 from autolink infos // test if force utf8 from autolink infos
if ((fileType == FileType::CSource || if ((fileType == FileType::CSource ||
fileType == FileType::CppSource) && pSettings->editor().enableAutolink() ){ fileType == FileType::CppSource) && pSettings->editor().enableAutolink() ){
Editor* editor = pMainWindow->editorList()->getEditor(); Editor* editor = pMainWindow->editorList()->getOpenedEditorByFilename(mFilename);
if (editor) { if (editor) {
PCppParser parser = editor->parser(); PCppParser parser = editor->parser();
if (parser) { if (parser) {
@ -340,7 +340,7 @@ QString Compiler::getCharsetArgument(const QByteArray& encoding,FileType fileTyp
} }
QSet<QString> parsedFiles; QSet<QString> parsedFiles;
forceExecUTF8 = parseForceUTF8ForAutolink( forceExecUTF8 = parseForceUTF8ForAutolink(
editor->filename(), mFilename,
parsedFiles, parsedFiles,
parser); parser);
} }

View File

@ -192,6 +192,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
mStatementColors = pMainWindow->statementColors(); mStatementColors = pMainWindow->statementColors();
if (mParentPageControl) { if (mParentPageControl) {
//first showEvent triggered here
mParentPageControl->addTab(this,""); mParentPageControl->addTab(this,"");
updateCaption(); updateCaption();
} }
@ -217,12 +218,13 @@ Editor::Editor(QWidget *parent, const QString& filename,
this, &Editor::onScrollBarValueChanged); this, &Editor::onScrollBarValueChanged);
mInited=true; mInited=true;
// if (!pMainWindow->openingFiles() //show event is trigged when this is added to the qtabwidget
// && !pMainWindow->openingProject()) { if (!pMainWindow->openingFiles()
// reparse(false); && !pMainWindow->openingProject()) {
// checkSyntaxInBack(); reparse(false);
// reparseTodo(); checkSyntaxInBack();
// } reparseTodo();
}
} }
Editor::~Editor() { Editor::~Editor() {
@ -3106,7 +3108,7 @@ void Editor::reparse(bool resetParser)
return; return;
if (!mParser->enabled()) if (!mParser->enabled())
return; return;
//qDebug()<<"reparse "<<mFilename;
//mParser->setEnabled(pSettings->codeCompletion().enabled()); //mParser->setEnabled(pSettings->codeCompletion().enabled());
ParserLanguage language = mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C; ParserLanguage language = mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C;
if (!inProject()) { if (!inProject()) {

View File

@ -66,6 +66,7 @@ CppParser::CppParser(QObject *parent) : QObject(parent)
CppParser::~CppParser() CppParser::~CppParser()
{ {
//qDebug()<<"delete parser";
while (true) { while (true) {
//wait for all methods finishes running //wait for all methods finishes running
{ {
@ -75,6 +76,7 @@ CppParser::~CppParser()
break; break;
} }
} }
//qDebug()<<"waiting for parse finished";
QThread::msleep(50); QThread::msleep(50);
QCoreApplication* app = QApplication::instance(); QCoreApplication* app = QApplication::instance();
app->processEvents(); app->processEvents();