diff --git a/NEWS.md b/NEWS.md index d407b474..b9300a12 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index cfeb7cbd..d6b65313 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -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); } } diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 9ce69b01..fc228a73 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -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(this); // Set all properties + newUnit->setEncoding(toByteArray(mOptions.encoding)); newUnit->setFileName(QDir(directory()).filePath(inFileName)); newUnit->setNew(false); newUnit->setEditor(nullptr);