1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 08:30:06 +02:00

Opt-out of check for updates persists after preference resets...

... These can happen in only two ways, using the application: from the Tools
menu, or using the Windows intaller program.

A review of all uses of wxFileConfig::DeleteAll() proves this.

The one special BoolSetting object was moved from UpdateManager to Prefs.cpp to
avoid a dependency cycle among source code files.
This commit is contained in:
Paul Licameli 2021-06-29 14:32:18 -04:00 committed by Paul Licameli
parent bfb79feed3
commit 870fc5d626
10 changed files with 42 additions and 14 deletions

View File

@ -241,7 +241,7 @@ void PopulatePreferences()
wxYES_NO, NULL); wxYES_NO, NULL);
if (action == wxYES) // reset if (action == wxYES) // reset
{ {
gPrefs->DeleteAll(); ResetPreferences();
writeLang = true; writeLang = true;
} }
} }

View File

@ -1943,6 +1943,9 @@ void PluginManager::Load()
if (!registry.HasGroup(REGROOT)) if (!registry.HasGroup(REGROOT))
{ {
// Must start over // Must start over
// This DeleteAll affects pluginregistry.cfg only, not audacity.cfg
// That is, the memory of on/off states of effect (and generator,
// analyzer, and tool) plug-ins
registry.DeleteAll(); registry.DeleteAll();
registry.Flush(); registry.Flush();
return; return;
@ -2286,7 +2289,7 @@ void PluginManager::Save()
{}, {}, FileNames::PluginRegistry()); {}, {}, FileNames::PluginRegistry());
auto &registry = *pRegistry; auto &registry = *pRegistry;
// Clear it out // Clear pluginregistry.cfg (not audacity.cfg)
registry.DeleteAll(); registry.DeleteAll();
// Write the version string // Write the version string

View File

@ -63,6 +63,9 @@
#include "MemoryX.h" #include "MemoryX.h"
#include <memory> #include <memory>
BoolSetting DefaultUpdatesCheckingFlag{
L"/Update/DefaultUpdatesChecking", true };
std::unique_ptr<FileConfig> ugPrefs {}; std::unique_ptr<FileConfig> ugPrefs {};
FileConfig *gPrefs = nullptr; FileConfig *gPrefs = nullptr;
@ -179,6 +182,25 @@ void InitPreferences( std::unique_ptr<FileConfig> uPrefs )
wxConfigBase::Set(gPrefs); wxConfigBase::Set(gPrefs);
} }
void ResetPreferences()
{
// Future: make this a static registry table, so the settings objects
// don't need to be defined in this source code file to avoid dependency
// cycles
std::pair<BoolSetting &, bool> stickyBoolSettings[] {
{DefaultUpdatesCheckingFlag, 0},
// ... others?
};
for (auto &pair : stickyBoolSettings)
pair.second = pair.first.Read();
bool savedValue = DefaultUpdatesCheckingFlag.Read();
gPrefs->DeleteAll();
for (auto &pair : stickyBoolSettings)
pair.first.Write(pair.second);
}
void FinishPreferences() void FinishPreferences()
{ {
if (gPrefs) { if (gPrefs) {

View File

@ -48,6 +48,12 @@
class wxFileName; class wxFileName;
void InitPreferences( std::unique_ptr<FileConfig> uPrefs ); void InitPreferences( std::unique_ptr<FileConfig> uPrefs );
//! Call this to reset preferences to an (almost)-"new" default state
/*!
There is at least one exception to that: user preferences we want to make
more "sticky." Notably, whether automatic update checking is preferred.
*/
void ResetPreferences();
void FinishPreferences(); void FinishPreferences();
extern AUDACITY_DLL_API FileConfig *gPrefs; extern AUDACITY_DLL_API FileConfig *gPrefs;
@ -423,4 +429,7 @@ struct AUDACITY_DLL_API PreferenceInitializer {
static void ReinitializeAll(); static void ReinitializeAll();
}; };
// Special extra-sticky settings
extern AUDACITY_DLL_API BoolSetting DefaultUpdatesCheckingFlag;
#endif #endif

View File

@ -647,6 +647,7 @@ wxString EffectManager::GetPreset(const PluginID & ID, const wxString & params,
return preset; return preset;
} }
// This cleans a config "file" backed by a string in memory.
eap.DeleteAll(); eap.DeleteAll();
eap.Write(wxT("Use Preset"), preset); eap.Write(wxT("Use Preset"), preset);

View File

@ -384,7 +384,7 @@ void OnResetConfig(const CommandContext &context)
menuManager.mLastAnalyzer = ""; menuManager.mLastAnalyzer = "";
menuManager.mLastTool = ""; menuManager.mLastTool = "";
gPrefs->DeleteAll(); ResetPreferences();
// Directory will be reset on next restart. // Directory will be reset on next restart.
FileNames::UpdateDefaultPath(FileNames::Operation::Temp, TempDirectory::DefaultTempDir()); FileNames::UpdateDefaultPath(FileNames::Operation::Temp, TempDirectory::DefaultTempDir());

View File

@ -72,7 +72,7 @@ void ApplicationPrefs::PopulateOrExchange(ShuttleGui & S)
{ {
S.TieCheckBox( S.TieCheckBox(
XO("&Check for Updates...").Stripped(TranslatableString::Ellipses | TranslatableString::MenuCodes), XO("&Check for Updates...").Stripped(TranslatableString::Ellipses | TranslatableString::MenuCodes),
UpdatesCheckingSettings::DefaultUpdatesCheckingFlag); DefaultUpdatesCheckingFlag);
} }
S.EndStatic(); S.EndStatic();
S.EndScroller(); S.EndScroller();

View File

@ -24,9 +24,6 @@
#include <mutex> #include <mutex>
#include <cstdint> #include <cstdint>
BoolSetting UpdatesCheckingSettings::DefaultUpdatesCheckingFlag{
L"/Update/DefaultUpdatesChecking", true };
static const char* prefsUpdateScheduledTime = "/Update/UpdateScheduledTime"; static const char* prefsUpdateScheduledTime = "/Update/UpdateScheduledTime";
@ -127,7 +124,7 @@ void UpdateManager::GetUpdates(bool ignoreNetworkErrors)
void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event)) void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event))
{ {
bool updatesCheckingEnabled = UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Read(); bool updatesCheckingEnabled = DefaultUpdatesCheckingFlag.Read();
if (updatesCheckingEnabled && IsTimeForUpdatesChecking()) if (updatesCheckingEnabled && IsTimeForUpdatesChecking())
GetUpdates(true); GetUpdates(true);

View File

@ -18,10 +18,6 @@
#include <wx/event.h> #include <wx/event.h>
#include <wx/timer.h> #include <wx/timer.h>
namespace UpdatesCheckingSettings {
extern AUDACITY_DLL_API BoolSetting DefaultUpdatesCheckingFlag;
}
/// A class that managing of updates. /// A class that managing of updates.
/** /**
Opt-in request and show update dialog by the scheduled time. Opt-in request and show update dialog by the scheduled time.

View File

@ -45,7 +45,7 @@ UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, const VersionPatch& vers
S.Id (DontShowID).AddCheckBox ( S.Id (DontShowID).AddCheckBox (
XO ("Don't show this again at start up"), XO ("Don't show this again at start up"),
!UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Read()); !DefaultUpdatesCheckingFlag.Read());
S.Prop(1).AddSpace(1, 0, 1); S.Prop(1).AddSpace(1, 0, 1);
@ -80,7 +80,7 @@ void UpdatePopupDialog::OnSkip (wxCommandEvent&)
void UpdatePopupDialog::OnDontShow (wxCommandEvent& event) void UpdatePopupDialog::OnDontShow (wxCommandEvent& event)
{ {
UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Write(!event.IsChecked()); DefaultUpdatesCheckingFlag.Write(!event.IsChecked());
} }
HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent) HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)