mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 23:59:37 +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:
parent
bfb79feed3
commit
870fc5d626
@ -241,7 +241,7 @@ void PopulatePreferences()
|
||||
wxYES_NO, NULL);
|
||||
if (action == wxYES) // reset
|
||||
{
|
||||
gPrefs->DeleteAll();
|
||||
ResetPreferences();
|
||||
writeLang = true;
|
||||
}
|
||||
}
|
||||
|
@ -1943,6 +1943,9 @@ void PluginManager::Load()
|
||||
if (!registry.HasGroup(REGROOT))
|
||||
{
|
||||
// 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.Flush();
|
||||
return;
|
||||
@ -2286,7 +2289,7 @@ void PluginManager::Save()
|
||||
{}, {}, FileNames::PluginRegistry());
|
||||
auto ®istry = *pRegistry;
|
||||
|
||||
// Clear it out
|
||||
// Clear pluginregistry.cfg (not audacity.cfg)
|
||||
registry.DeleteAll();
|
||||
|
||||
// Write the version string
|
||||
|
@ -63,6 +63,9 @@
|
||||
#include "MemoryX.h"
|
||||
#include <memory>
|
||||
|
||||
BoolSetting DefaultUpdatesCheckingFlag{
|
||||
L"/Update/DefaultUpdatesChecking", true };
|
||||
|
||||
std::unique_ptr<FileConfig> ugPrefs {};
|
||||
|
||||
FileConfig *gPrefs = nullptr;
|
||||
@ -179,6 +182,25 @@ void InitPreferences( std::unique_ptr<FileConfig> uPrefs )
|
||||
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()
|
||||
{
|
||||
if (gPrefs) {
|
||||
|
@ -48,6 +48,12 @@
|
||||
class wxFileName;
|
||||
|
||||
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();
|
||||
|
||||
extern AUDACITY_DLL_API FileConfig *gPrefs;
|
||||
@ -423,4 +429,7 @@ struct AUDACITY_DLL_API PreferenceInitializer {
|
||||
static void ReinitializeAll();
|
||||
};
|
||||
|
||||
// Special extra-sticky settings
|
||||
extern AUDACITY_DLL_API BoolSetting DefaultUpdatesCheckingFlag;
|
||||
|
||||
#endif
|
||||
|
@ -647,6 +647,7 @@ wxString EffectManager::GetPreset(const PluginID & ID, const wxString & params,
|
||||
return preset;
|
||||
}
|
||||
|
||||
// This cleans a config "file" backed by a string in memory.
|
||||
eap.DeleteAll();
|
||||
|
||||
eap.Write(wxT("Use Preset"), preset);
|
||||
|
@ -384,7 +384,7 @@ void OnResetConfig(const CommandContext &context)
|
||||
menuManager.mLastAnalyzer = "";
|
||||
menuManager.mLastTool = "";
|
||||
|
||||
gPrefs->DeleteAll();
|
||||
ResetPreferences();
|
||||
|
||||
// Directory will be reset on next restart.
|
||||
FileNames::UpdateDefaultPath(FileNames::Operation::Temp, TempDirectory::DefaultTempDir());
|
||||
|
@ -72,7 +72,7 @@ void ApplicationPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.TieCheckBox(
|
||||
XO("&Check for Updates...").Stripped(TranslatableString::Ellipses | TranslatableString::MenuCodes),
|
||||
UpdatesCheckingSettings::DefaultUpdatesCheckingFlag);
|
||||
DefaultUpdatesCheckingFlag);
|
||||
}
|
||||
S.EndStatic();
|
||||
S.EndScroller();
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include <mutex>
|
||||
#include <cstdint>
|
||||
|
||||
BoolSetting UpdatesCheckingSettings::DefaultUpdatesCheckingFlag{
|
||||
L"/Update/DefaultUpdatesChecking", true };
|
||||
|
||||
static const char* prefsUpdateScheduledTime = "/Update/UpdateScheduledTime";
|
||||
|
||||
|
||||
@ -127,7 +124,7 @@ void UpdateManager::GetUpdates(bool ignoreNetworkErrors)
|
||||
|
||||
void UpdateManager::OnTimer(wxTimerEvent& WXUNUSED(event))
|
||||
{
|
||||
bool updatesCheckingEnabled = UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Read();
|
||||
bool updatesCheckingEnabled = DefaultUpdatesCheckingFlag.Read();
|
||||
|
||||
if (updatesCheckingEnabled && IsTimeForUpdatesChecking())
|
||||
GetUpdates(true);
|
||||
|
@ -18,10 +18,6 @@
|
||||
#include <wx/event.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
namespace UpdatesCheckingSettings {
|
||||
extern AUDACITY_DLL_API BoolSetting DefaultUpdatesCheckingFlag;
|
||||
}
|
||||
|
||||
/// A class that managing of updates.
|
||||
/**
|
||||
Opt-in request and show update dialog by the scheduled time.
|
||||
|
@ -45,7 +45,7 @@ UpdatePopupDialog::UpdatePopupDialog (wxWindow* parent, const VersionPatch& vers
|
||||
|
||||
S.Id (DontShowID).AddCheckBox (
|
||||
XO ("Don't show this again at start up"),
|
||||
!UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Read());
|
||||
!DefaultUpdatesCheckingFlag.Read());
|
||||
|
||||
S.Prop(1).AddSpace(1, 0, 1);
|
||||
|
||||
@ -80,7 +80,7 @@ void UpdatePopupDialog::OnSkip (wxCommandEvent&)
|
||||
|
||||
void UpdatePopupDialog::OnDontShow (wxCommandEvent& event)
|
||||
{
|
||||
UpdatesCheckingSettings::DefaultUpdatesCheckingFlag.Write(!event.IsChecked());
|
||||
DefaultUpdatesCheckingFlag.Write(!event.IsChecked());
|
||||
}
|
||||
|
||||
HtmlWindow* UpdatePopupDialog::AddHtmlContent (wxWindow* parent)
|
||||
|
Loading…
x
Reference in New Issue
Block a user