- fix: the project compiler options is not correctly read when open old dev-c++ project

This commit is contained in:
Roy Qu 2022-09-24 21:24:58 +08:00
parent 8b3490243c
commit 40cae133ba
3 changed files with 24 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Red Panda C++ Version 1.4
- fix: crash when create non C/C++ source file in project - fix: crash when create non C/C++ source file in project
- fix: can't open text project file in the editor - fix: can't open text project file in the editor
- change: when create non-text project file, don't auto open it - change: when create non-text project file, don't auto open it
- fix: the project compiler options is not correctly read when open old dev-c++ project
Red Panda C++ Version 1.3 Red Panda C++ Version 1.3

View File

@ -1769,6 +1769,28 @@ void Project::loadOptions(SimpleIni& ini)
QByteArray oldCompilerOptions = ini.GetValue("Project", "CompilerSettings", ""); QByteArray oldCompilerOptions = ini.GetValue("Project", "CompilerSettings", "");
if (!oldCompilerOptions.isEmpty()) { if (!oldCompilerOptions.isEmpty()) {
//version 2 compatibility //version 2 compatibility
// test if it is created by old dev-c++
SimpleIni::TNamesDepend oKeys;
ini.GetAllKeys("Project", oKeys);
bool isNewDev=false;
for(const SimpleIni::Entry& entry:oKeys) {
QString key(entry.pItem);
if (key=="UsePrecompiledHeader"
|| key == "CompilerSetType"
|| key == "StaticLink"
|| key == "AddCharset"
|| key == "ExecEncoding"
|| key == "Encoding"
|| key == "UseUTF8") {
isNewDev = true;
break;
}
}
if (!isNewDev && oldCompilerOptions.length()>=25) {
char t = oldCompilerOptions[18];
oldCompilerOptions[18]=oldCompilerOptions[21];
oldCompilerOptions[21]=t;
}
for (int i=0;i<oldCompilerOptions.length();i++) { for (int i=0;i<oldCompilerOptions.length();i++) {
QString key = pSettings->compilerSets().getKeyFromCompilerCompatibleIndex(i); QString key = pSettings->compilerSets().getKeyFromCompilerCompatibleIndex(i);
PCompilerOption pOption = CompilerInfoManager::getCompilerOption( PCompilerOption pOption = CompilerInfoManager::getCompilerOption(

View File

@ -2893,7 +2893,7 @@ void Settings::CompilerSets::prepareCompatibleIndex()
//old settings compatibility, don't reorder, add or remove items //old settings compatibility, don't reorder, add or remove items
mCompilerCompatibleIndex.append(CC_CMD_OPT_ANSI); mCompilerCompatibleIndex.append(CC_CMD_OPT_ANSI);
mCompilerCompatibleIndex.append(CC_CMD_OPT_NO_ASM "gcc_cmd_opt_no_asm"); mCompilerCompatibleIndex.append(CC_CMD_OPT_NO_ASM);
mCompilerCompatibleIndex.append(CC_CMD_OPT_TRADITIONAL_CPP); mCompilerCompatibleIndex.append(CC_CMD_OPT_TRADITIONAL_CPP);
mCompilerCompatibleIndex.append(CC_CMD_OPT_ARCH); mCompilerCompatibleIndex.append(CC_CMD_OPT_ARCH);