- enhancement: Keep project compile warning & error infos in the issues table, before project file is edited.

This commit is contained in:
Roy Qu 2023-02-24 12:17:30 +08:00
parent e5c6ea1a43
commit a7c73200d5
4 changed files with 86 additions and 28 deletions

View File

@ -8,7 +8,8 @@ Red Panda C++ Version 2.14
- change: Remove nasm support
- change: Don't stop debug when breakpoint can't be set
- fix: "Generate assembly" menu item is wrongly enabled for new GNU assembly files
- Enhancement: New file templates for C / C++ / GAS files
- enhancement: New file templates for C / C++ / GAS files
- enhancement: Keep project compile warning & error infos in the issues table, before project file is edited.
Red Panda C++ Version 2.13

View File

@ -125,7 +125,7 @@ void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebu
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onProjectCompileStarted);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::clearToolsOutput);
connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput);
@ -159,7 +159,7 @@ void CompilerManager::cleanProject(std::shared_ptr<Project> project)
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onProjectCompileStarted);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::clearToolsOutput);
connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput);
@ -210,7 +210,7 @@ void CompilerManager::checkSyntax(const QString &filename, const QByteArray& enc
mBackgroundSyntaxChecker->setProject(project);
connect(mBackgroundSyntaxChecker, &Compiler::finished, mBackgroundSyntaxChecker, &QThread::deleteLater);
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue);
connect(mBackgroundSyntaxChecker, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted);
connect(mBackgroundSyntaxChecker, &Compiler::compileStarted, pMainWindow, &MainWindow::onSyntaxCheckStarted);
connect(mBackgroundSyntaxChecker, &Compiler::compileFinished, this, &CompilerManager::onSyntaxCheckFinished);
//connect(mBackgroundSyntaxChecker, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput);
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);

View File

@ -109,20 +109,22 @@ static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
MainWindow* pMainWindow;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
mFullInitialized(false),
mSearchInFilesDialog(nullptr),
mSearchDialog(nullptr),
mReplaceDialog(nullptr),
mQuitting(false),
mClosingProject(false),
mCheckSyntaxInBack(false),
mShouldRemoveAllSettings(false),
mClosing(false),
mClosingAll(false),
mOpenningFiles(false),
mSystemTurnedOff(false)
: QMainWindow{parent},
ui{new Ui::MainWindow},
mFullInitialized{false},
mSearchInFilesDialog{nullptr},
mSearchDialog{nullptr},
mReplaceDialog{nullptr},
mQuitting{false},
mClosingProject{false},
mCheckSyntaxInBack{false},
mShouldRemoveAllSettings{false},
mClosing{false},
mClosingAll{false},
mOpenningFiles{false},
mSystemTurnedOff{false},
mCompileIssuesState{CompileIssuesState::None}
{
ui->setupUi(this);
addActions( this->findChildren<QAction *>(QString(), Qt::FindChildrenRecursively));
@ -1846,7 +1848,6 @@ void MainWindow::checkSyntaxInBack(Editor *e)
// if not devEditor.AutoCheckSyntax then
// Exit;
//not c or cpp file
if (!e->isNew()) {
FileType fileType = getFileType(e->filename());
if (fileType != FileType::CSource
&& fileType != FileType::CppSource
@ -1854,7 +1855,6 @@ void MainWindow::checkSyntaxInBack(Editor *e)
&& fileType != FileType::CppHeader
)
return;
}
if (mCompilerManager->backgroundSyntaxChecking())
return;
if (mCompilerManager->compiling())
@ -1864,6 +1864,14 @@ void MainWindow::checkSyntaxInBack(Editor *e)
if (mCheckSyntaxInBack)
return;
if (mCompileIssuesState==CompileIssuesState::ProjectCompilationResultFilled
|| mCompileIssuesState==CompileIssuesState::ProjectCompiling) {
if (e->inProject() && mProject) {
if (!e->modified())
return;
}
}
mCheckSyntaxInBack=true;
clearIssues();
CompileTarget target =getCompileTarget();
@ -5442,6 +5450,8 @@ void MainWindow::on_actionSave_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor) {
if (editor->inProject() && mCompileIssuesState == CompileIssuesState::ProjectCompilationResultFilled)
mCompileIssuesState = CompileIssuesState::None;
editor->save();
// if (editor->inProject() && (mProject))
// mProject->saveAll();
@ -5505,6 +5515,10 @@ void MainWindow::logToolsOutput(const QString& msg)
void MainWindow::onCompileIssue(PCompileIssue issue)
{
if (issue->filename.isEmpty())
return;
if (issue->filename.contains("*"))
return;
ui->tableIssues->addIssue(issue);
// Update tab caption
@ -5538,7 +5552,17 @@ void MainWindow::clearTodos()
void MainWindow::onCompileStarted()
{
//do nothing
mCompileIssuesState = CompileIssuesState::Compiling;
}
void MainWindow::onProjectCompileStarted()
{
mCompileIssuesState = CompileIssuesState::ProjectCompiling;
}
void MainWindow::onSyntaxCheckStarted()
{
mCompileIssuesState = CompileIssuesState::SyntaxChecking;
}
void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
@ -5550,6 +5574,7 @@ void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
mCompileSuccessionTask = nullptr;
return;
}
// Update tab caption
int i = ui->tabMessages->indexOf(ui->tabIssues);
if (i!=-1) {
@ -5570,6 +5595,21 @@ void MainWindow::onCompileFinished(QString filename, bool isCheckSyntax)
}
}
switch(mCompileIssuesState) {
case CompileIssuesState::Compiling:
mCompileIssuesState = CompileIssuesState::CompilationResultFilled;
break;
case CompileIssuesState::ProjectCompiling:
mCompileIssuesState = CompileIssuesState::ProjectCompilationResultFilled;
break;
case CompileIssuesState::SyntaxChecking:
mCompileIssuesState = CompileIssuesState::SyntaxCheckResultFilled;
break;
default:
break;
}
if (isCheckSyntax) {
if (!CompilerInfoManager::supportSyntaxCheck(pSettings->compilerSets().defaultSet()->compilerType())) {
QDir dir(extractFileDir(filename));
@ -6795,6 +6835,8 @@ void MainWindow::on_actionSaveAll_triggered()
mFileSystemWatcher.blockSignals(oldBlock);
});
if (mProject) {
if (mCompileIssuesState == CompileIssuesState::ProjectCompilationResultFilled)
mCompileIssuesState = CompileIssuesState::None;
mProject->saveAll();
}
@ -7738,6 +7780,7 @@ void MainWindow::clearIssues()
ui->tabMessages->setTabText(i, tr("Issues"));
}
ui->tableIssues->clearIssues();
mCompileIssuesState = CompileIssuesState::None;
}
void MainWindow::doCompileRun(RunType runType)

View File

@ -80,6 +80,17 @@ class MainWindow : public QMainWindow
{
Q_OBJECT
enum class CompileIssuesState{
CompilationResultFilled,
Compiling,
ProjectCompilationResultFilled,
ProjectCompiling,
SyntaxChecking,
SyntaxCheckResultFilled,
None
};
enum class CompileSuccessionTaskType {
None,
RunNormal,
@ -225,6 +236,8 @@ public slots:
void clearToolsOutput();
void clearTodos();
void onCompileStarted();
void onProjectCompileStarted();
void onSyntaxCheckStarted();
void onCompileFinished(QString filename, bool isCheckSyntax);
void onCompileErrorOccured(const QString& reason);
void onRunErrorOccured(const QString& reason);
@ -852,6 +865,7 @@ private:
QPoint mEditorContextMenuPos;
QTcpServer mTcpServer;
QColor mErrorColor;
CompileIssuesState mCompileIssuesState;
QSet<QString> mFilesChangedNotifying;