diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index d13ce2a97..e014c66f6 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1360,6 +1360,13 @@ bool AudacityApp::OnInit() // Initialize preferences and language InitPreferences(); 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() ); + return false; + } #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__) this->AssociateFileTypes(); diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 808686db9..100e14fac 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -61,6 +61,7 @@ #include #include "FileNames.h" +#include "Internat.h" #include "MemoryX.h" #include "Languages.h" @@ -220,6 +221,20 @@ void InitPreferences() wxConfigBase::Set(gPrefs); } +bool CheckWritablePreferences() +{ + return gPrefs->Write("/TEST", true) && gPrefs->Flush(); +} + +wxString UnwritablePreferencesErrorMessage() +{ + wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg")); + return wxString::Format( + _("Audacity cannot start because the settings file at %s is not writable."), + configFileName.GetFullPath() + ); +} + void FinishPreferences() { if (gPrefs) { diff --git a/src/Prefs.h b/src/Prefs.h index 4cb454e0e..9c98c67e6 100644 --- a/src/Prefs.h +++ b/src/Prefs.h @@ -38,6 +38,8 @@ #include // to declare custom event types void InitPreferences(); +bool CheckWritablePreferences(); +wxString UnwritablePreferencesErrorMessage(); void FinishPreferences(); class AudacityPrefs;