From a16562f6cefb442f6dfe81f678ca04c76727ba66 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Sat, 9 Oct 2021 11:33:23 +0800 Subject: [PATCH] - fix: The Enter key in the numpad doesn't work - fix: The compiled executable not fully write to the disk before run it - fix: settings object not correctly released when exit - fix: shouldn't check syntax when save modifications before compiling - fix: shouldn't scroll to the end of the last line when update compile logs - fix: can't debug project --- NEWS.md | 9 +- RedPandaIDE/compiler/compilermanager.cpp | 30 ++++--- RedPandaIDE/compiler/compilermanager.h | 6 +- RedPandaIDE/editor.cpp | 8 +- RedPandaIDE/mainwindow.cpp | 105 ++++++++++++----------- RedPandaIDE/mainwindow.h | 2 +- RedPandaIDE/mainwindow.ui | 2 +- RedPandaIDE/settings.cpp | 27 +++--- 8 files changed, 104 insertions(+), 85 deletions(-) diff --git a/NEWS.md b/NEWS.md index e1191278..0df866a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,13 @@ -Version 0.6.1 - - fix: editor deadlock +Version 0.6.2 - fix: The Enter key in the numpad doesn't work - fix: The compiled executable not fully write to the disk before run it - fix: settings object not correctly released when exit + - fix: shouldn't check syntax when save modifications before compiling + - fix: shouldn't scroll to the end of the last line when update compile logs + - fix: can't debug project + +Version 0.6.1 + - fix: editor deadlock Version 0.6.0 - fix: old data not displayed when editing code snippets diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index d6530295..938fdb20 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -65,10 +65,11 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin mCompileErrorCount = 0; mCompiler = new FileCompiler(filename,encoding,silent,onlyCheckSyntax); mCompiler->setRebuild(rebuild); - connect(mCompiler, &Compiler::compileFinished, this ,&CompilerManager::onCompileFinished); + connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater); + connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished); connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted); - connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); + connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); @@ -92,9 +93,12 @@ void CompilerManager::compileProject(std::shared_ptr project, bool rebu mCompileErrorCount = 0; mCompiler = new ProjectCompiler(project,silent,onlyCheckSyntax); mCompiler->setRebuild(rebuild); - connect(mCompiler, &Compiler::compileFinished, this ,&CompilerManager::onCompileFinished); + connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater); + connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished); + connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); - connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); + connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted); + connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); @@ -120,9 +124,12 @@ void CompilerManager::cleanProject(std::shared_ptr project) compiler->setOnlyClean(true); mCompiler->setRebuild(false); mCompiler = compiler; - connect(mCompiler, &Compiler::compileFinished, this ,&CompilerManager::onCompileFinished); + connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater); + connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished); + connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); - connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); + connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted); + connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); @@ -166,9 +173,10 @@ void CompilerManager::checkSyntax(const QString &filename, const QString &conten mSyntaxCheckErrorCount = 0; mBackgroundSyntaxChecker = new StdinCompiler(filename,content,isAscii,true,true); mBackgroundSyntaxChecker->setProject(project); - connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, this ,&CompilerManager::onSyntaxCheckFinished); + connect(mBackgroundSyntaxChecker, &Compiler::finished, mBackgroundSyntaxChecker, &QThread::deleteLater); connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue); - connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished); + connect(mBackgroundSyntaxChecker, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted); + connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, this, &CompilerManager::onSyntaxCheckFinished); connect(mBackgroundSyntaxChecker, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mBackgroundSyntaxChecker, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); @@ -210,7 +218,7 @@ void CompilerManager::stopCompile() void CompilerManager::stopCheckSyntax() { - QMutexLocker locker(&mCompileMutex); + QMutexLocker locker(&mBackgroundSyntaxCheckMutex); if (mBackgroundSyntaxChecker!=nullptr) mBackgroundSyntaxChecker->stopCompile(); } @@ -223,8 +231,8 @@ bool CompilerManager::canCompile(const QString &filename) void CompilerManager::onCompileFinished() { QMutexLocker locker(&mCompileMutex); - delete mCompiler; mCompiler=nullptr; + pMainWindow->onCompileFinished(false); } void CompilerManager::onRunnerTerminated() @@ -245,8 +253,8 @@ void CompilerManager::onCompileIssue(PCompileIssue issue) void CompilerManager::onSyntaxCheckFinished() { QMutexLocker locker(&mBackgroundSyntaxCheckMutex); - delete mBackgroundSyntaxChecker; mBackgroundSyntaxChecker=nullptr; + pMainWindow->onCompileFinished(true); } void CompilerManager::onSyntaxCheckIssue(PCompileIssue issue) diff --git a/RedPandaIDE/compiler/compilermanager.h b/RedPandaIDE/compiler/compilermanager.h index 2c8ec63c..92cf5fec 100644 --- a/RedPandaIDE/compiler/compilermanager.h +++ b/RedPandaIDE/compiler/compilermanager.h @@ -52,9 +52,9 @@ private: int mSyntaxCheckIssueCount; Compiler* mBackgroundSyntaxChecker; ExecutableRunner* mRunner; - QMutex mCompileMutex; - QMutex mBackgroundSyntaxCheckMutex; - QMutex mRunnerMutex; + QRecursiveMutex mCompileMutex; + QRecursiveMutex mBackgroundSyntaxCheckMutex; + QRecursiveMutex mRunnerMutex; }; class CompileError : public BaseError { diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 8c268d5b..db40570a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -194,9 +194,6 @@ void Editor::saveFile(const QString &filename) { QFile file(filename); this->lines()->SaveToFile(file,mEncodingOption,mFileEncoding); pMainWindow->updateForEncodingInfo(); - if (pSettings->editor().syntaxCheckWhenSave()) - checkSyntaxInBack(); - reparseTodo(); } void Editor::convertToEncoding(const QByteArray &encoding) @@ -238,6 +235,9 @@ bool Editor::save(bool force, bool doReparse) { if (doReparse && mParser) { reparse(); } + if (doReparse && pSettings->editor().syntaxCheckWhenSave()) + checkSyntaxInBack(); + reparseTodo(); return true; } @@ -328,6 +328,8 @@ bool Editor::saveAs(const QString &name, bool fromProject){ if (pSettings->editor().syntaxCheckWhenSave()) pMainWindow->checkSyntaxInBack(this); + reparseTodo(); + if (pSettings->editor().readOnlySytemHeader() && (!mParser->isSystemHeaderFile(mFilename) && !mParser->isProjectHeaderFile(mFilename))) { diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 39dcda8f..aa698b70 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1114,11 +1114,7 @@ void MainWindow::debug() host.replace('\\','/'); mDebugger->sendCommand("exec-file", '"' + host + '"'); } - for (int i=0;iunits().count();i++) { - QString file = mProject->units()[i]->fileName(); - file.replace('\\','/'); - mDebugger->sendCommand("file", '"'+file+ '"'); - } + includeOrSkipDirs(mProject->options().includes, pSettings->debugger().skipProjectLibraries()); includeOrSkipDirs(mProject->options().libs, @@ -2535,6 +2531,7 @@ void MainWindow::on_actionOpen_triggered() } void MainWindow::closeEvent(QCloseEvent *event) { + mQuitting = true; if (!mShouldRemoveAllSettings) { Settings::UI& settings = pSettings->ui(); settings.setMainWindowState(saveState()); @@ -2558,6 +2555,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { } if (!mEditorList->closeAll(false)) { + mQuitting = false; event->ignore(); return ; } @@ -2695,6 +2693,8 @@ void MainWindow::onCompilerSetChanged(int index) void MainWindow::onCompileLog(const QString &msg) { ui->txtCompilerOutput->appendPlainText(msg); + ui->txtCompilerOutput->moveCursor(QTextCursor::End); + ui->txtCompilerOutput->moveCursor(QTextCursor::StartOfLine); ui->txtCompilerOutput->ensureCursorVisible(); } @@ -2726,22 +2726,27 @@ void MainWindow::onCompileStarted() ui->txtCompilerOutput->clear(); } -void MainWindow::onCompileFinished() +void MainWindow::onCompileFinished(bool isCheckSyntax) { + if (mQuitting) { + if (isCheckSyntax) + mCheckSyntaxInBack = false; + else + mCompileSuccessionTask = nullptr; + return; + } // Update tab caption int i = ui->tabMessages->indexOf(ui->tabIssues); - if (i==-1) - return; - ui->tabMessages->setTabText(i, tr("Issues") + + if (i==-1) { + ui->tabMessages->setTabText(i, tr("Issues") + QString(" (%1)").arg(ui->tableIssues->model()->rowCount())); + } // Close it if there's nothing to show - if (mCheckSyntaxInBack) { + if (isCheckSyntax) { // check syntax in back, don't change message panel } else if ( (ui->tableIssues->count() == 0) -// and (ResourceOutput.Items.Count = 0) -// and devData.AutoCloseProgress ) { openCloseBottomPanel(false); // Or open it if there is anything to show @@ -2750,12 +2755,6 @@ void MainWindow::onCompileFinished() if (ui->tabMessages->currentIndex() != i) { ui->tabMessages->setCurrentIndex(i); } -// end else if (ResourceOutput.Items.Count > 0) then begin -// if MessageControl.ActivePage <> ResSheet then begin -// MessageControl.ActivePage := ResSheet; -// fMessageControlChanged := False; -// end; -// end; openCloseBottomPanel(true); } } @@ -2765,46 +2764,48 @@ void MainWindow::onCompileFinished() e->invalidate(); } - //run succession task if there aren't any errors - if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) { - QThread::msleep(500); // wait for exec file writed to disk; - switch (mCompileSuccessionTask->type) { - case MainWindow::CompileSuccessionTaskType::Run: - runExecutable(mCompileSuccessionTask->filename); - break; - case MainWindow::CompileSuccessionTaskType::Debug: - debug(); - break; - } - mCompileSuccessionTask.reset(); - // Jump to problem location, sorted by significance - } else if ((mCompilerManager->compileIssueCount() > 0) && (!mCheckSyntaxInBack)) { - // First try to find errors - for (int i=0;itableIssues->count();i++) { - PCompileIssue issue = ui->tableIssues->issue(i); - if (issue->type == CompileIssueType::Error) { - if (e && e->filename() != issue->filename) - continue; - ui->tableIssues->selectRow(i); - QModelIndex index =ui->tableIssues->model()->index(i,0); - emit ui->tableIssues->doubleClicked(index); + if (!isCheckSyntax) { + //run succession task if there aren't any errors + if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) { + switch (mCompileSuccessionTask->type) { + case MainWindow::CompileSuccessionTaskType::Run: + runExecutable(mCompileSuccessionTask->filename); + break; + case MainWindow::CompileSuccessionTaskType::Debug: + debug(); break; } - } + mCompileSuccessionTask.reset(); + // Jump to problem location, sorted by significance + } else if ((mCompilerManager->compileIssueCount() > 0) && (!mCheckSyntaxInBack)) { + // First try to find errors + for (int i=0;itableIssues->count();i++) { + PCompileIssue issue = ui->tableIssues->issue(i); + if (issue->type == CompileIssueType::Error) { + if (e && e->filename() != issue->filename) + continue; + ui->tableIssues->selectRow(i); + QModelIndex index =ui->tableIssues->model()->index(i,0); + emit ui->tableIssues->doubleClicked(index); + break; + } + } - // Then try to find warnings - for (int i=0;itableIssues->count();i++) { - PCompileIssue issue = ui->tableIssues->issue(i); - if (issue->type == CompileIssueType::Warning) { - if (e && e->filename() != issue->filename) - continue; - ui->tableIssues->selectRow(i); - QModelIndex index =ui->tableIssues->model()->index(i,0); - emit ui->tableIssues->doubleClicked(index); + // Then try to find warnings + for (int i=0;itableIssues->count();i++) { + PCompileIssue issue = ui->tableIssues->issue(i); + if (issue->type == CompileIssueType::Warning) { + if (e && e->filename() != issue->filename) + continue; + ui->tableIssues->selectRow(i); + QModelIndex index =ui->tableIssues->model()->index(i,0); + emit ui->tableIssues->doubleClicked(index); + } } } + } else { + mCheckSyntaxInBack=false; } - mCheckSyntaxInBack=false; updateCompileActions(); updateAppTitle(); } diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 0b4c34ef..8da9a385 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -139,7 +139,7 @@ public slots: void onCompileLog(const QString& msg); void onCompileIssue(PCompileIssue issue); void onCompileStarted(); - void onCompileFinished(); + void onCompileFinished(bool isCheckSyntax); void onCompileErrorOccured(const QString& reason); void onRunErrorOccured(const QString& reason); void onRunFinished(); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 4303e27a..601a3698 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -283,7 +283,7 @@ QTabWidget::South - 3 + 1 diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 936c21f8..f73fb0d1 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2210,10 +2210,11 @@ static void setReleaseOptions(Settings::PCompilerSet pSet) { pSet->setOption(pOption,'1'); } - pOption = pSet->findOption("-static"); - if (pOption) { - pSet->setOption(pOption,'1'); - } +// pOption = pSet->findOption("-static"); +// if (pOption) { +// pSet->setOption(pOption,'1'); +// } + pSet->setStaticLink(true); } static void setDebugOptions(Settings::PCompilerSet pSet) { @@ -2229,10 +2230,11 @@ static void setDebugOptions(Settings::PCompilerSet pSet) { if (pOption) { pSet->setOption(pOption,'1'); } - pOption = pSet->findOption("-static"); - if (pOption) { - pSet->setOption(pOption,'1'); - } +// pOption = pSet->findOption("-static"); +// if (pOption) { +// pSet->setOption(pOption,'1'); +// } + pSet->setStaticLink(false); } static void setProfileOptions(Settings::PCompilerSet pSet) { @@ -2241,10 +2243,11 @@ static void setProfileOptions(Settings::PCompilerSet pSet) { pSet->setOption(pOption,'1'); } - pOption = pSet->findOption("-static"); - if (pOption) { - pSet->setOption(pOption,'1'); - } +// pOption = pSet->findOption("-static"); +// if (pOption) { +// pSet->setOption(pOption,'1'); +// } + pSet->setStaticLink(false); } void Settings::CompilerSets::addSets(const QString &folder)