mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 16:37:12 +01:00
Break cycle of Prefs, Languages, FileNames
This commit is contained in:
@@ -1358,13 +1358,15 @@ bool AudacityApp::OnInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize preferences and language
|
// Initialize preferences and language
|
||||||
InitPreferences();
|
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
||||||
|
InitPreferences( configFileName );
|
||||||
PopulatePreferences();
|
PopulatePreferences();
|
||||||
// This test must follow PopulatePreferences, because if an error message
|
// This test must follow PopulatePreferences, because if an error message
|
||||||
// must be shown, we need internationalization to have been initialized
|
// must be shown, we need internationalization to have been initialized
|
||||||
// first, which was done in PopulatePreferences
|
// first, which was done in PopulatePreferences
|
||||||
if ( !CheckWritablePreferences() ) {
|
if ( !CheckWritablePreferences() ) {
|
||||||
::AudacityMessageBox( UnwritablePreferencesErrorMessage() );
|
::AudacityMessageBox(
|
||||||
|
UnwritablePreferencesErrorMessage( configFileName ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,8 @@
|
|||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
#include <wx/stdpaths.h>
|
#include <wx/stdpaths.h>
|
||||||
|
|
||||||
#include "FileNames.h"
|
|
||||||
#include "Internat.h"
|
#include "Internat.h"
|
||||||
#include "MemoryX.h"
|
#include "MemoryX.h"
|
||||||
#include "Languages.h"
|
|
||||||
|
|
||||||
std::unique_ptr<AudacityPrefs> ugPrefs {};
|
std::unique_ptr<AudacityPrefs> ugPrefs {};
|
||||||
|
|
||||||
@@ -206,12 +204,10 @@ bool AudacityPrefs::GetEditClipsCanMove()
|
|||||||
return editClipsCanMove;
|
return editClipsCanMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitPreferences()
|
void InitPreferences( const wxFileName &configFileName )
|
||||||
{
|
{
|
||||||
wxString appName = wxTheApp->GetAppName();
|
wxString appName = wxTheApp->GetAppName();
|
||||||
|
|
||||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
|
||||||
|
|
||||||
ugPrefs = std::make_unique<AudacityPrefs>
|
ugPrefs = std::make_unique<AudacityPrefs>
|
||||||
(appName, wxEmptyString,
|
(appName, wxEmptyString,
|
||||||
configFileName.GetFullPath(),
|
configFileName.GetFullPath(),
|
||||||
@@ -226,9 +222,8 @@ bool CheckWritablePreferences()
|
|||||||
return gPrefs->Write("/TEST", true) && gPrefs->Flush();
|
return gPrefs->Write("/TEST", true) && gPrefs->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString UnwritablePreferencesErrorMessage()
|
wxString UnwritablePreferencesErrorMessage( const wxFileName &configFileName )
|
||||||
{
|
{
|
||||||
wxFileName configFileName(FileNames::DataDir(), wxT("audacity.cfg"));
|
|
||||||
return wxString::Format(
|
return wxString::Format(
|
||||||
_("Audacity cannot start because the settings file at %s is not writable."),
|
_("Audacity cannot start because the settings file at %s is not writable."),
|
||||||
configFileName.GetFullPath()
|
configFileName.GetFullPath()
|
||||||
|
|||||||
@@ -37,9 +37,11 @@
|
|||||||
#include <wx/fileconf.h> // to inherit wxFileConfig
|
#include <wx/fileconf.h> // to inherit wxFileConfig
|
||||||
#include <wx/event.h> // to declare custom event types
|
#include <wx/event.h> // to declare custom event types
|
||||||
|
|
||||||
void InitPreferences();
|
class wxFileName;
|
||||||
|
|
||||||
|
void InitPreferences( const wxFileName &configFileName );
|
||||||
bool CheckWritablePreferences();
|
bool CheckWritablePreferences();
|
||||||
wxString UnwritablePreferencesErrorMessage();
|
wxString UnwritablePreferencesErrorMessage( const wxFileName &configFileName );
|
||||||
void FinishPreferences();
|
void FinishPreferences();
|
||||||
|
|
||||||
class AudacityPrefs;
|
class AudacityPrefs;
|
||||||
|
|||||||
Reference in New Issue
Block a user