- fix: add unit to project not correctly set new unit file's encoding

This commit is contained in:
royqh1979@gmail.com 2021-11-15 19:30:24 +08:00
parent 2b3f8a644f
commit 0f130291aa
3 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,6 @@
Version 0.8.10 For Dev-C++ 7 Beta
- fix: Shouldn't update auto link settings, if the header name to be modified is unchanged
- fix: add unit to project not correctly set new unit file's encoding
Version 0.8.9 For Dev-C++ 7 Beta
- fix: text color of labels in statusbar not correctly updated when change theme

View File

@ -340,14 +340,14 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->editor()->fileEncoding(),
defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_ASCII) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->encoding(),
defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_SYSTEM_DEFAULT) {
} else if (unit->encoding()==ENCODING_SYSTEM_DEFAULT) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(defaultSystemEncoding,
defaultSystemEncoding);
} else if (unit->encoding()!=ENCODING_ASCII && !unit->encoding().isEmpty()) {
encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2")
.arg(unit->encoding(),
defaultSystemEncoding);
}
}

View File

@ -260,7 +260,7 @@ PProjectUnit Project::newUnit(PFolderNode parentNode, const QString& customFileN
newUnit->setOverrideBuildCmd(false);
newUnit->setBuildCmd("");
newUnit->setModified(true);
newUnit->setEncoding(toByteArray(options().encoding));
newUnit->setEncoding(toByteArray(mOptions.encoding));
return newUnit;
}
@ -285,7 +285,7 @@ Editor *Project::openUnit(int index)
editor = pMainWindow->editorList()->newEditor(fullPath, encoding, true, unit->isNew());
editor->setInProject(true);
unit->setEditor(editor);
unit->setEncoding(encoding);
//unit->setEncoding(encoding);
editor->activate();
loadUnitLayout(editor,index);
return editor;
@ -788,6 +788,7 @@ PProjectUnit Project::addUnit(const QString &inFileName, PFolderNode parentNode,
newUnit = std::make_shared<ProjectUnit>(this);
// Set all properties
newUnit->setEncoding(toByteArray(mOptions.encoding));
newUnit->setFileName(QDir(directory()).filePath(inFileName));
newUnit->setNew(false);
newUnit->setEditor(nullptr);