- fix: "UTF-8 BOM" can't be correctly loaded as project file's encoding.

- fix: Project file's encoding is not correctly updated after converted manually.
This commit is contained in:
Roy Qu 2023-07-31 21:07:45 +08:00
parent b80cfe71f8
commit 9be257e8e8
3 changed files with 13 additions and 1 deletions

View File

@ -5,6 +5,8 @@ Red Panda C++ Version 2.24
- fix: Code completion doesn't work if "min id length to show completion" is not 1. - fix: Code completion doesn't work if "min id length to show completion" is not 1.
- fix: english typos. (thanks for sangiye0@github) - fix: english typos. (thanks for sangiye0@github)
- fix: Goto definition/declaration may choose wrong symbol is multiple files are opened and symbols have the same name. - fix: Goto definition/declaration may choose wrong symbol is multiple files are opened and symbols have the same name.
- fix: "UTF-8 BOM" can't be correctly loaded as project file's encoding.
- fix: Project file's encoding is not correctly updated after converted manually.
Red Panda C++ Version 2.23 Red Panda C++ Version 2.23

View File

@ -337,6 +337,13 @@ void Editor::convertToEncoding(const QByteArray &encoding)
mEncodingOption = encoding; mEncodingOption = encoding;
setModified(true); setModified(true);
save(); save();
if (mProject) {
PProjectUnit unit = mProject->findUnit(this);
if (unit) {
unit->setEncoding(mEncodingOption);
unit->setRealEncoding(mFileEncoding);
}
}
} }
bool Editor::save(bool force, bool doReparse) { bool Editor::save(bool force, bool doReparse) {

View File

@ -242,7 +242,10 @@ void Project::open()
newUnit->setOverrideBuildCmd(ini.GetBoolValue(groupName,"OverrideBuildCmd", false)); newUnit->setOverrideBuildCmd(ini.GetBoolValue(groupName,"OverrideBuildCmd", false));
newUnit->setBuildCmd(fromByteArray(ini.GetValue(groupName,"BuildCmd", ""))); newUnit->setBuildCmd(fromByteArray(ini.GetValue(groupName,"BuildCmd", "")));
newUnit->setEncoding(ini.GetValue(groupName, "FileEncoding",ENCODING_PROJECT)); newUnit->setEncoding(ini.GetValue(groupName, "FileEncoding",ENCODING_PROJECT));
if (QTextCodec::codecForName(newUnit->encoding())==nullptr) { if (newUnit->encoding()!=ENCODING_UTF16_BOM &&
newUnit->encoding()!=ENCODING_UTF8_BOM &&
newUnit->encoding()!=ENCODING_UTF32_BOM &&
QTextCodec::codecForName(newUnit->encoding())==nullptr) {
newUnit->setEncoding(ENCODING_PROJECT); newUnit->setEncoding(ENCODING_PROJECT);
} }
newUnit->setRealEncoding(ini.GetValue(groupName, "RealEncoding",ENCODING_ASCII)); newUnit->setRealEncoding(ini.GetValue(groupName, "RealEncoding",ENCODING_ASCII));