From 35e3c9af8dd85771b839d02777a7cb0c8cc0fa90 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 25 Jan 2023 10:28:55 +0800 Subject: [PATCH] - fix: Can't correctly set project file's encoding back to 'UTF-8'/'ANSI' in the project options dialog/files setting page. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 7 +++++-- RedPandaIDE/settingsdialog/projectfileswidget.cpp | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index f028617d..5b4b5ced 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ Red Panda C++ Version 2.10 - fix: Settings in Options/Tools/General is messed up when switching items in the list. - fix: Infos in the status bar not correctly updated when editor closed. - change: Project's encoding shouldn't be set to "auto detect" + - fix: Can't correctly set project file's encoding back to 'UTF-8'/'ANSI' in the project options dialog/files setting page. Red Panda C++ Version 2.9 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 3381708e..7169cc7e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -529,9 +529,12 @@ const QByteArray& Editor::encodingOption() const noexcept{ return mEncodingOption; } void Editor::setEncodingOption(const QByteArray& encoding) noexcept{ - if (mEncodingOption == encoding) + QByteArray newEncoding=encoding; + if (mProject && encoding==ENCODING_PROJECT) + newEncoding=mProject->options().encoding; + if (mEncodingOption == newEncoding) return; - mEncodingOption = encoding; + mEncodingOption = newEncoding; if (!isNew()) { try { loadFile(); diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.cpp b/RedPandaIDE/settingsdialog/projectfileswidget.cpp index 80718f49..bf2ead97 100644 --- a/RedPandaIDE/settingsdialog/projectfileswidget.cpp +++ b/RedPandaIDE/settingsdialog/projectfileswidget.cpp @@ -270,6 +270,8 @@ void ProjectFilesWidget::on_cbEncodingDetail_currentTextChanged(const QString &) PProjectUnit unit = currentUnit(); if(!unit) return; + if (ui->cbEncodingDetail->currentText().isEmpty()) + return; unit->setEncoding(ui->cbEncodingDetail->currentText().toUtf8()); }