diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 8c653f870..2581ec0ed 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1358,13 +1358,15 @@ bool AudacityApp::OnInit() #endif // Initialize preferences and language - InitPreferences(); + wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg")); + InitPreferences( configFileName ); PopulatePreferences(); // This test must follow PopulatePreferences, because if an error message // must be shown, we need internationalization to have been initialized // first, which was done in PopulatePreferences if ( !CheckWritablePreferences() ) { - ::AudacityMessageBox( UnwritablePreferencesErrorMessage() ); + ::AudacityMessageBox( + UnwritablePreferencesErrorMessage( configFileName ) ); return false; } diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 100e14fac..a26448b65 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -60,10 +60,8 @@ #include #include -#include "FileNames.h" #include "Internat.h" #include "MemoryX.h" -#include "Languages.h" std::unique_ptr ugPrefs {}; @@ -206,12 +204,10 @@ bool AudacityPrefs::GetEditClipsCanMove() return editClipsCanMove; } -void InitPreferences() +void InitPreferences( const wxFileName &configFileName ) { wxString appName = wxTheApp->GetAppName(); - wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg")); - ugPrefs = std::make_unique (appName, wxEmptyString, configFileName.GetFullPath(), @@ -226,9 +222,8 @@ bool CheckWritablePreferences() return gPrefs->Write("/TEST", true) && gPrefs->Flush(); } -wxString UnwritablePreferencesErrorMessage() +wxString UnwritablePreferencesErrorMessage( const wxFileName &configFileName ) { - wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg")); return wxString::Format( _("Audacity cannot start because the settings file at %s is not writable."), configFileName.GetFullPath() diff --git a/src/Prefs.h b/src/Prefs.h index 9c98c67e6..e94d4446b 100644 --- a/src/Prefs.h +++ b/src/Prefs.h @@ -37,9 +37,11 @@ #include // to inherit wxFileConfig #include // to declare custom event types -void InitPreferences(); +class wxFileName; + +void InitPreferences( const wxFileName &configFileName ); bool CheckWritablePreferences(); -wxString UnwritablePreferencesErrorMessage(); +wxString UnwritablePreferencesErrorMessage( const wxFileName &configFileName ); void FinishPreferences(); class AudacityPrefs;