- 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: Remove nasm support
- change: Don't stop debug when breakpoint can't be set - change: Don't stop debug when breakpoint can't be set
- fix: "Generate assembly" menu item is wrongly enabled for new GNU assembly files - 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 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::compileFinished, this, &CompilerManager::onCompileFinished);
connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); 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::compileStarted, pMainWindow, &MainWindow::clearToolsOutput);
connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput); 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::compileFinished, this, &CompilerManager::onCompileFinished);
connect(mCompiler, &Compiler::compileIssue, this, &CompilerManager::onCompileIssue); 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::compileStarted, pMainWindow, &MainWindow::clearToolsOutput);
connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput); connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput);
@ -210,7 +210,7 @@ void CompilerManager::checkSyntax(const QString &filename, const QByteArray& enc
mBackgroundSyntaxChecker->setProject(project); mBackgroundSyntaxChecker->setProject(project);
connect(mBackgroundSyntaxChecker, &Compiler::finished, mBackgroundSyntaxChecker, &QThread::deleteLater); connect(mBackgroundSyntaxChecker, &Compiler::finished, mBackgroundSyntaxChecker, &QThread::deleteLater);
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, this, &CompilerManager::onSyntaxCheckIssue); 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::compileFinished, this, &CompilerManager::onSyntaxCheckFinished);
//connect(mBackgroundSyntaxChecker, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput); //connect(mBackgroundSyntaxChecker, &Compiler::compileOutput, pMainWindow, &MainWindow::logToolsOutput);
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);

View File

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

View File

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