fix: options not correctly inited when project compiler set changed.

This commit is contained in:
Roy Qu 2024-04-14 21:51:28 +08:00
parent e78799f561
commit e184466fda
2 changed files with 17 additions and 5 deletions

View File

@ -44,10 +44,10 @@ void ProjectCompilerWidget::refreshOptions()
ui->tabOptions->resetUI(pSet,mOptions); ui->tabOptions->resetUI(pSet,mOptions);
ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink); ui->chkStaticLink->setChecked(mStaticLink);
ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset); ui->chkAddCharset->setChecked(mAddCharset);
QByteArray execEncoding = pMainWindow->project()->options().execEncoding; QByteArray execEncoding = mExecCharset;
if (execEncoding == ENCODING_AUTO_DETECT if (execEncoding == ENCODING_AUTO_DETECT
|| execEncoding == ENCODING_SYSTEM_DEFAULT || execEncoding == ENCODING_SYSTEM_DEFAULT
|| execEncoding == ENCODING_UTF8) { || execEncoding == ENCODING_UTF8) {
@ -75,11 +75,12 @@ void ProjectCompilerWidget::doLoad()
Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex()); Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex());
if (mOptions.isEmpty() && pSet) if (mOptions.isEmpty() && pSet)
mOptions = pSet->compileOptions(); mOptions = pSet->compileOptions();
mStaticLink = pMainWindow->project()->options().staticLink;
mAddCharset = pMainWindow->project()->options().addCharset;
mExecCharset = pMainWindow->project()->options().execEncoding;
ui->cbCompilerSet->blockSignals(true); ui->cbCompilerSet->blockSignals(true);
ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet); ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet);
ui->cbCompilerSet->blockSignals(false); ui->cbCompilerSet->blockSignals(false);
ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset);
ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink);
refreshOptions(); refreshOptions();
} }
@ -99,6 +100,10 @@ void ProjectCompilerWidget::doSave()
} else { } else {
pMainWindow->project()->options().execEncoding = ui->cbEncoding->currentData().toString().toLocal8Bit(); pMainWindow->project()->options().execEncoding = ui->cbEncoding->currentData().toString().toLocal8Bit();
} }
mOptions = pMainWindow->project()->options().compilerOptions;
mStaticLink = pMainWindow->project()->options().staticLink;
mAddCharset = pMainWindow->project()->options().addCharset;
mExecCharset = pMainWindow->project()->options().execEncoding;
pMainWindow->project()->saveOptions(); pMainWindow->project()->saveOptions();
} }
@ -169,6 +174,10 @@ void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int index)
return; return;
} }
mOptions = pSet->compileOptions(); mOptions = pSet->compileOptions();
mStaticLink = pSet->staticLink();
mAddCharset = pSet->autoAddCharsetParams();
mExecCharset = pSet->execCharset().toUtf8();
setSettingsChanged(); setSettingsChanged();
//project->saveOptions(); //project->saveOptions();
} }

View File

@ -37,6 +37,9 @@ private:
private: private:
Ui::ProjectCompilerWidget *ui; Ui::ProjectCompilerWidget *ui;
QMap<QString,QString> mOptions; QMap<QString,QString> mOptions;
bool mStaticLink;
bool mAddCharset;
QByteArray mExecCharset;
// SettingsWidget interface // SettingsWidget interface
protected: protected: