diff --git a/CHANGELOG.md b/CHANGELOG.md index c761192e..1475e90f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). +## [1.6.1a / 5.61.1] - 2022-12-?? + +### Fixed +- improved fix for [#2495](https://github.com/sandboxie-plus/Sandboxie/issues/2495) + + ## [1.6.1 / 5.61.1] - 2022-12-04 diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/SbieIni.cpp b/SandboxiePlus/QSbieAPI/Sandboxie/SbieIni.cpp index fa7d85a6..c174b62c 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/SbieIni.cpp +++ b/SandboxiePlus/QSbieAPI/Sandboxie/SbieIni.cpp @@ -61,13 +61,20 @@ SB_STATUS CSbieIni::SetBool(const QString& Setting, bool Value) SB_STATUS CSbieIni::SetBoolSafe(const QString& Setting, bool Value) { + QString StrValue = Value ? "y" : "n"; + bool bAdd = true; QStringList Values = GetTextList(Setting, false); - foreach(const QString & StrValue, Values) { - if (StrValue.contains(",")) + foreach(const QString & CurValue, Values) { + if (CurValue.contains(",")) continue; - DelValue(Setting, StrValue); + if (CurValue == StrValue) + bAdd = false; + else + DelValue(Setting, CurValue); } - return InsertText(Setting, Value ? "y" : "n"); + if(bAdd) + return InsertText(Setting, StrValue); + return SB_OK; } QString CSbieIni::GetText(const QString& Setting, const QString& Default, bool bWithGlobal, bool bNoExpand, bool withTemplates) const diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp index f39c6594..fe28d5e9 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp @@ -759,27 +759,33 @@ void COptionsWindow::WriteAdvancedCheck(QCheckBox* pCheck, const QString& Name, if (!pCheck->isEnabled()) return; - QStringList Values = m_pBox->GetTextList(Name, false); - foreach(const QString & StrValue, Values) { - if (StrValue.contains(",")) - continue; - m_pBox->DelValue(Name, StrValue); - } - - SB_STATUS Status; + QString StrValue; if (pCheck->checkState() == Qt::Checked) { if (!OnValue.isEmpty()) - Status = m_pBox->InsertText(Name, OnValue); + StrValue = OnValue; } else if (pCheck->checkState() == Qt::Unchecked) { if (!OffValue.isEmpty()) - Status = m_pBox->InsertText(Name, OffValue); + StrValue = OffValue; } - if (!Status) - throw Status; + QStringList Values = m_pBox->GetTextList(Name, false); + foreach(const QString & CurValue, Values) { + if (CurValue.contains(",")) + continue; + if (!StrValue.isEmpty() && CurValue == StrValue) + StrValue.clear(); + else + m_pBox->DelValue(Name, CurValue); + } + + if (!StrValue.isEmpty()) { + SB_STATUS Status = m_pBox->InsertText(Name, StrValue); + if (!Status) + throw Status; + } } void COptionsWindow::WriteText(const QString& Name, const QString& Value)