- 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
This commit is contained in:
royqh1979@gmail.com 2021-10-09 11:33:23 +08:00
parent c58ddf7073
commit a16562f6ce
8 changed files with 104 additions and 85 deletions

View File

@ -1,8 +1,13 @@
Version 0.6.1 Version 0.6.2
- fix: editor deadlock
- fix: The Enter key in the numpad doesn't work - fix: The Enter key in the numpad doesn't work
- fix: The compiled executable not fully write to the disk before run it - fix: The compiled executable not fully write to the disk before run it
- fix: settings object not correctly released when exit - 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 Version 0.6.0
- fix: old data not displayed when editing code snippets - fix: old data not displayed when editing code snippets

View File

@ -65,10 +65,11 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin
mCompileErrorCount = 0; mCompileErrorCount = 0;
mCompiler = new FileCompiler(filename,encoding,silent,onlyCheckSyntax); mCompiler = new FileCompiler(filename,encoding,silent,onlyCheckSyntax);
mCompiler->setRebuild(rebuild); 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::compileIssue, this, &CompilerManager::onCompileIssue);
connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted); connect(mCompiler, &Compiler::compileStarted, pMainWindow, &MainWindow::onCompileStarted);
connect(mCompiler, &Compiler::compileFinished, pMainWindow, &MainWindow::onCompileFinished);
connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog); connect(mCompiler, &Compiler::compileOutput, pMainWindow, &MainWindow::onCompileLog);
connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);
connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured);
@ -92,9 +93,12 @@ void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebu
mCompileErrorCount = 0; mCompileErrorCount = 0;
mCompiler = new ProjectCompiler(project,silent,onlyCheckSyntax); mCompiler = new ProjectCompiler(project,silent,onlyCheckSyntax);
mCompiler->setRebuild(rebuild); 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::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::compileOutput, pMainWindow, &MainWindow::onCompileLog);
connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);
connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured);
@ -120,9 +124,12 @@ void CompilerManager::cleanProject(std::shared_ptr<Project> project)
compiler->setOnlyClean(true); compiler->setOnlyClean(true);
mCompiler->setRebuild(false); mCompiler->setRebuild(false);
mCompiler = compiler; 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::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::compileOutput, pMainWindow, &MainWindow::onCompileLog);
connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mCompiler, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);
connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); connect(mCompiler, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured);
@ -166,9 +173,10 @@ void CompilerManager::checkSyntax(const QString &filename, const QString &conten
mSyntaxCheckErrorCount = 0; mSyntaxCheckErrorCount = 0;
mBackgroundSyntaxChecker = new StdinCompiler(filename,content,isAscii,true,true); mBackgroundSyntaxChecker = new StdinCompiler(filename,content,isAscii,true,true);
mBackgroundSyntaxChecker->setProject(project); 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::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::compileOutput, pMainWindow, &MainWindow::onCompileLog);
connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue); connect(mBackgroundSyntaxChecker, &Compiler::compileIssue, pMainWindow, &MainWindow::onCompileIssue);
connect(mBackgroundSyntaxChecker, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured); connect(mBackgroundSyntaxChecker, &Compiler::compileErrorOccured, pMainWindow, &MainWindow::onCompileErrorOccured);
@ -210,7 +218,7 @@ void CompilerManager::stopCompile()
void CompilerManager::stopCheckSyntax() void CompilerManager::stopCheckSyntax()
{ {
QMutexLocker locker(&mCompileMutex); QMutexLocker locker(&mBackgroundSyntaxCheckMutex);
if (mBackgroundSyntaxChecker!=nullptr) if (mBackgroundSyntaxChecker!=nullptr)
mBackgroundSyntaxChecker->stopCompile(); mBackgroundSyntaxChecker->stopCompile();
} }
@ -223,8 +231,8 @@ bool CompilerManager::canCompile(const QString &filename)
void CompilerManager::onCompileFinished() void CompilerManager::onCompileFinished()
{ {
QMutexLocker locker(&mCompileMutex); QMutexLocker locker(&mCompileMutex);
delete mCompiler;
mCompiler=nullptr; mCompiler=nullptr;
pMainWindow->onCompileFinished(false);
} }
void CompilerManager::onRunnerTerminated() void CompilerManager::onRunnerTerminated()
@ -245,8 +253,8 @@ void CompilerManager::onCompileIssue(PCompileIssue issue)
void CompilerManager::onSyntaxCheckFinished() void CompilerManager::onSyntaxCheckFinished()
{ {
QMutexLocker locker(&mBackgroundSyntaxCheckMutex); QMutexLocker locker(&mBackgroundSyntaxCheckMutex);
delete mBackgroundSyntaxChecker;
mBackgroundSyntaxChecker=nullptr; mBackgroundSyntaxChecker=nullptr;
pMainWindow->onCompileFinished(true);
} }
void CompilerManager::onSyntaxCheckIssue(PCompileIssue issue) void CompilerManager::onSyntaxCheckIssue(PCompileIssue issue)

View File

@ -52,9 +52,9 @@ private:
int mSyntaxCheckIssueCount; int mSyntaxCheckIssueCount;
Compiler* mBackgroundSyntaxChecker; Compiler* mBackgroundSyntaxChecker;
ExecutableRunner* mRunner; ExecutableRunner* mRunner;
QMutex mCompileMutex; QRecursiveMutex mCompileMutex;
QMutex mBackgroundSyntaxCheckMutex; QRecursiveMutex mBackgroundSyntaxCheckMutex;
QMutex mRunnerMutex; QRecursiveMutex mRunnerMutex;
}; };
class CompileError : public BaseError { class CompileError : public BaseError {

View File

@ -194,9 +194,6 @@ void Editor::saveFile(const QString &filename) {
QFile file(filename); QFile file(filename);
this->lines()->SaveToFile(file,mEncodingOption,mFileEncoding); this->lines()->SaveToFile(file,mEncodingOption,mFileEncoding);
pMainWindow->updateForEncodingInfo(); pMainWindow->updateForEncodingInfo();
if (pSettings->editor().syntaxCheckWhenSave())
checkSyntaxInBack();
reparseTodo();
} }
void Editor::convertToEncoding(const QByteArray &encoding) void Editor::convertToEncoding(const QByteArray &encoding)
@ -238,6 +235,9 @@ bool Editor::save(bool force, bool doReparse) {
if (doReparse && mParser) { if (doReparse && mParser) {
reparse(); reparse();
} }
if (doReparse && pSettings->editor().syntaxCheckWhenSave())
checkSyntaxInBack();
reparseTodo();
return true; return true;
} }
@ -328,6 +328,8 @@ bool Editor::saveAs(const QString &name, bool fromProject){
if (pSettings->editor().syntaxCheckWhenSave()) if (pSettings->editor().syntaxCheckWhenSave())
pMainWindow->checkSyntaxInBack(this); pMainWindow->checkSyntaxInBack(this);
reparseTodo();
if (pSettings->editor().readOnlySytemHeader() if (pSettings->editor().readOnlySytemHeader()
&& (!mParser->isSystemHeaderFile(mFilename) && !mParser->isProjectHeaderFile(mFilename))) { && (!mParser->isSystemHeaderFile(mFilename) && !mParser->isProjectHeaderFile(mFilename))) {

View File

@ -1114,11 +1114,7 @@ void MainWindow::debug()
host.replace('\\','/'); host.replace('\\','/');
mDebugger->sendCommand("exec-file", '"' + host + '"'); mDebugger->sendCommand("exec-file", '"' + host + '"');
} }
for (int i=0;i<mProject->units().count();i++) {
QString file = mProject->units()[i]->fileName();
file.replace('\\','/');
mDebugger->sendCommand("file", '"'+file+ '"');
}
includeOrSkipDirs(mProject->options().includes, includeOrSkipDirs(mProject->options().includes,
pSettings->debugger().skipProjectLibraries()); pSettings->debugger().skipProjectLibraries());
includeOrSkipDirs(mProject->options().libs, includeOrSkipDirs(mProject->options().libs,
@ -2535,6 +2531,7 @@ void MainWindow::on_actionOpen_triggered()
} }
void MainWindow::closeEvent(QCloseEvent *event) { void MainWindow::closeEvent(QCloseEvent *event) {
mQuitting = true;
if (!mShouldRemoveAllSettings) { if (!mShouldRemoveAllSettings) {
Settings::UI& settings = pSettings->ui(); Settings::UI& settings = pSettings->ui();
settings.setMainWindowState(saveState()); settings.setMainWindowState(saveState());
@ -2558,6 +2555,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
} }
if (!mEditorList->closeAll(false)) { if (!mEditorList->closeAll(false)) {
mQuitting = false;
event->ignore(); event->ignore();
return ; return ;
} }
@ -2695,6 +2693,8 @@ void MainWindow::onCompilerSetChanged(int index)
void MainWindow::onCompileLog(const QString &msg) void MainWindow::onCompileLog(const QString &msg)
{ {
ui->txtCompilerOutput->appendPlainText(msg); ui->txtCompilerOutput->appendPlainText(msg);
ui->txtCompilerOutput->moveCursor(QTextCursor::End);
ui->txtCompilerOutput->moveCursor(QTextCursor::StartOfLine);
ui->txtCompilerOutput->ensureCursorVisible(); ui->txtCompilerOutput->ensureCursorVisible();
} }
@ -2726,22 +2726,27 @@ void MainWindow::onCompileStarted()
ui->txtCompilerOutput->clear(); ui->txtCompilerOutput->clear();
} }
void MainWindow::onCompileFinished() void MainWindow::onCompileFinished(bool isCheckSyntax)
{ {
if (mQuitting) {
if (isCheckSyntax)
mCheckSyntaxInBack = false;
else
mCompileSuccessionTask = nullptr;
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) {
return;
ui->tabMessages->setTabText(i, tr("Issues") + ui->tabMessages->setTabText(i, tr("Issues") +
QString(" (%1)").arg(ui->tableIssues->model()->rowCount())); QString(" (%1)").arg(ui->tableIssues->model()->rowCount()));
}
// Close it if there's nothing to show // Close it if there's nothing to show
if (mCheckSyntaxInBack) { if (isCheckSyntax) {
// check syntax in back, don't change message panel // check syntax in back, don't change message panel
} else if ( } else if (
(ui->tableIssues->count() == 0) (ui->tableIssues->count() == 0)
// and (ResourceOutput.Items.Count = 0)
// and devData.AutoCloseProgress
) { ) {
openCloseBottomPanel(false); openCloseBottomPanel(false);
// Or open it if there is anything to show // Or open it if there is anything to show
@ -2750,12 +2755,6 @@ void MainWindow::onCompileFinished()
if (ui->tabMessages->currentIndex() != i) { if (ui->tabMessages->currentIndex() != i) {
ui->tabMessages->setCurrentIndex(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); openCloseBottomPanel(true);
} }
} }
@ -2765,9 +2764,9 @@ void MainWindow::onCompileFinished()
e->invalidate(); e->invalidate();
} }
if (!isCheckSyntax) {
//run succession task if there aren't any errors //run succession task if there aren't any errors
if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) { if (mCompileSuccessionTask && mCompilerManager->compileErrorCount()==0) {
QThread::msleep(500); // wait for exec file writed to disk;
switch (mCompileSuccessionTask->type) { switch (mCompileSuccessionTask->type) {
case MainWindow::CompileSuccessionTaskType::Run: case MainWindow::CompileSuccessionTaskType::Run:
runExecutable(mCompileSuccessionTask->filename); runExecutable(mCompileSuccessionTask->filename);
@ -2804,7 +2803,9 @@ void MainWindow::onCompileFinished()
} }
} }
} }
} else {
mCheckSyntaxInBack=false; mCheckSyntaxInBack=false;
}
updateCompileActions(); updateCompileActions();
updateAppTitle(); updateAppTitle();
} }

View File

@ -139,7 +139,7 @@ public slots:
void onCompileLog(const QString& msg); void onCompileLog(const QString& msg);
void onCompileIssue(PCompileIssue issue); void onCompileIssue(PCompileIssue issue);
void onCompileStarted(); void onCompileStarted();
void onCompileFinished(); void onCompileFinished(bool isCheckSyntax);
void onCompileErrorOccured(const QString& reason); void onCompileErrorOccured(const QString& reason);
void onRunErrorOccured(const QString& reason); void onRunErrorOccured(const QString& reason);
void onRunFinished(); void onRunFinished();

View File

@ -283,7 +283,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabIssues"> <widget class="QWidget" name="tabIssues">
<attribute name="icon"> <attribute name="icon">

View File

@ -2210,10 +2210,11 @@ static void setReleaseOptions(Settings::PCompilerSet pSet) {
pSet->setOption(pOption,'1'); pSet->setOption(pOption,'1');
} }
pOption = pSet->findOption("-static"); // pOption = pSet->findOption("-static");
if (pOption) { // if (pOption) {
pSet->setOption(pOption,'1'); // pSet->setOption(pOption,'1');
} // }
pSet->setStaticLink(true);
} }
static void setDebugOptions(Settings::PCompilerSet pSet) { static void setDebugOptions(Settings::PCompilerSet pSet) {
@ -2229,10 +2230,11 @@ static void setDebugOptions(Settings::PCompilerSet pSet) {
if (pOption) { if (pOption) {
pSet->setOption(pOption,'1'); pSet->setOption(pOption,'1');
} }
pOption = pSet->findOption("-static"); // pOption = pSet->findOption("-static");
if (pOption) { // if (pOption) {
pSet->setOption(pOption,'1'); // pSet->setOption(pOption,'1');
} // }
pSet->setStaticLink(false);
} }
static void setProfileOptions(Settings::PCompilerSet pSet) { static void setProfileOptions(Settings::PCompilerSet pSet) {
@ -2241,10 +2243,11 @@ static void setProfileOptions(Settings::PCompilerSet pSet) {
pSet->setOption(pOption,'1'); pSet->setOption(pOption,'1');
} }
pOption = pSet->findOption("-static"); // pOption = pSet->findOption("-static");
if (pOption) { // if (pOption) {
pSet->setOption(pOption,'1'); // pSet->setOption(pOption,'1');
} // }
pSet->setStaticLink(false);
} }
void Settings::CompilerSets::addSets(const QString &folder) void Settings::CompilerSets::addSets(const QString &folder)