From 038fb22cff69fe4f324da7661434de427f6a590c Mon Sep 17 00:00:00 2001 From: okrc <29057533+okrc@users.noreply.github.com> Date: Tue, 20 Sep 2022 11:40:28 +0800 Subject: [PATCH] Clean up the invalid values that do not exist for m_Collapsed. Clean up the invalid Box names in BoxDisplayOrder. --- SandboxiePlus/SandMan/SandMan.cpp | 2 ++ SandboxiePlus/SandMan/Views/SbieView.cpp | 27 ++++++++++++++++++++++++ SandboxiePlus/SandMan/Views/SbieView.h | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 80dcfbbe..6e879d7f 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -1603,6 +1603,8 @@ void CSandMan::OnStatusChanged() auto AllBoxes = theAPI->GetAllBoxes(); + m_pBoxView->ClearUserUIConfig(AllBoxes); + foreach(const QString & Key, theConf->ListKeys("SizeCache")) { if (!AllBoxes.contains(Key.toLower()) || !theConf->GetBool("Options/WatchBoxSize", false)) theConf->DelValue("SizeCache/" + Key); diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index e98962e0..4fef0991 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -1241,6 +1241,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& SandB if (!Status.IsError()) { theConf->DelValue("SizeCache/" + Name); + m_Collapsed.remove(Name); for (auto I = m_Groups.begin(); I != m_Groups.end(); ++I) { if (I.value().removeOne(Name)) @@ -1720,6 +1721,32 @@ void CSbieView::ReloadUserConfig() if (Collapsed.isEmpty()) Collapsed = theAPI->GetUserSettings()->GetText("BoxCollapsedView"); m_Collapsed = SplitStr(Collapsed, ",").toSet(); + + ClearUserUIConfig(); +} + +void CSbieView::ClearUserUIConfig(const QMap AllBoxes) { + if (!AllBoxes.isEmpty()) + { + for (auto I = m_Groups.begin(); I != m_Groups.end(); ++I) { + QStringList Temp = I.value(); + foreach(QString Name, I.value()) { + if (AllBoxes.contains(Name.toLower()) || m_Groups.keys().contains(Name)) + continue; + Temp.removeOne(Name); + } + I.value() = Temp; + } + } + + QSet Temp = m_Collapsed; + foreach(QString Name, m_Collapsed) + { + if (!count_if(m_Groups.begin(), m_Groups.end(), + [Name](const QStringList& item)->int { return item.contains(Name); })) + Temp.remove(Name); + } + m_Collapsed = Temp; } void CSbieView::SaveUserConfig() diff --git a/SandboxiePlus/SandMan/Views/SbieView.h b/SandboxiePlus/SandMan/Views/SbieView.h index efab22ae..98a0e456 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.h +++ b/SandboxiePlus/SandMan/Views/SbieView.h @@ -40,6 +40,7 @@ public slots: void Clear(); void Refresh(); void ReloadUserConfig(); + void ClearUserUIConfig(QMap AllBoxes = QMap()); void SaveUserConfig(); private slots: @@ -175,4 +176,4 @@ private: QList m_CurSandBoxes; QList m_CurProcesses; -}; \ No newline at end of file +};