- fix: rename project file will wrongly set it's encoding to 'ASCII';

- fix: can't make project
This commit is contained in:
Roy Qu 2023-01-15 15:47:08 +08:00
parent 48446aab02
commit 0f746957a5
3 changed files with 3 additions and 2 deletions

View File

@ -7,6 +7,7 @@ Red Panda C++ Version 2.9
- enhancement: Create a temporary copy of the current file when saving files (it's removed after the saving sucessfully finished). - enhancement: Create a temporary copy of the current file when saving files (it's removed after the saving sucessfully finished).
- enhancement: Auto backup editing contents. (Save editing contents 3 seconds after input stopped. Auto delete when editor successfully closed) - enhancement: Auto backup editing contents. (Save editing contents 3 seconds after input stopped. Auto delete when editor successfully closed)
- enhancement: Add "Auto backup editing contents" option in options/editor/auto save - enhancement: Add "Auto backup editing contents" option in options/editor/auto save
- fix: rename project file will wrongly set it's encoding to 'ASCII';
Red Panda C++ Version 2.8 Red Panda C++ Version 2.8

View File

@ -1219,7 +1219,7 @@ PProjectUnit Project::internalAddUnit(const QString &inFileName, PProjectModelNo
newUnit->setFileName(QDir(directory()).filePath(inFileName)); newUnit->setFileName(QDir(directory()).filePath(inFileName));
Editor * e= unitEditor(newUnit); Editor * e= unitEditor(newUnit);
if (e) { if (e) {
newUnit->setEncoding(e->fileEncoding()); newUnit->setEncoding(e->encodingOption());
e->setProject(this); e->setProject(this);
} else { } else {
newUnit->setEncoding(options().encoding.toUtf8()); newUnit->setEncoding(options().encoding.toUtf8());

View File

@ -395,7 +395,7 @@ bool stringToFile(const QString &str, const QString &fileName)
bool stringsToFile(const QStringList &list, const QString &fileName) bool stringsToFile(const QStringList &list, const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
return false; return false;
QTextStream stream(&file); QTextStream stream(&file);
for (const QString& s:list) { for (const QString& s:list) {