Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions clientgui/sg_BoincSimpleFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,15 @@ void CSimpleFrame::OnSelectDefaultSkin( wxCommandEvent& WXUNUSED(event) ) {
wxASSERT(pSkinManager);
wxASSERT(wxDynamicCast(pSkinManager, CSkinManager));

// The "Default" skin menu item is localized, but
// the name of the default skin is not localized
pSkinManager->SetSelectedSkin(pSkinManager->GetDefaultSkinName());

pSkinManager->ReloadSkin(pSkinManager->GetDefaultSkinName());

wxGetApp().SaveState();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The newly added persistence block in OnSelectDefaultSkin() is byte-for-byte identical to the block in OnSelectSkin() (both call wxGetApp().SaveState() then flush the config). This 5-line sequence is now duplicated across the two skin-selection handlers, so any future change to persistence (e.g., flushing under another config path or adding error handling) must be made in two places and can drift. The PR description acknowledges a helper could unify this but chose the two-line approach; a small private helper such as SaveSelectedSkin() would remove the duplication with minimal churn.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At clientgui/sg_BoincSimpleFrame.cpp, line 588:

<comment>The newly added persistence block in `OnSelectDefaultSkin()` is byte-for-byte identical to the block in `OnSelectSkin()` (both call `wxGetApp().SaveState()` then flush the config). This 5-line sequence is now duplicated across the two skin-selection handlers, so any future change to persistence (e.g., flushing under another config path or adding error handling) must be made in two places and can drift. The PR description acknowledges a helper could unify this but chose the two-line approach; a small private helper such as `SaveSelectedSkin()` would remove the duplication with minimal churn.</comment>

<file context>
@@ -584,6 +584,12 @@ void CSimpleFrame::OnSelectDefaultSkin( wxCommandEvent& WXUNUSED(event) ) {
     // the name of the default skin is not localized
     pSkinManager->ReloadSkin(pSkinManager->GetDefaultSkinName());
+
+    wxGetApp().SaveState();
+    wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
+    if (pConfig) {
</file context>

wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
if (pConfig) {
pConfig->Flush();
}
}


Expand Down Expand Up @@ -621,7 +627,10 @@ void CSimpleFrame::OnSelectSkin( wxCommandEvent& event ){
pSkinManager->ReloadSkin(newSkinName);

wxGetApp().SaveState();
wxConfigBase::Get(FALSE)->Flush();
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
if (pConfig) {
pConfig->Flush();
}
}


Expand Down
Loading