From b924c8ad62367cb1af203b4221d53158a588ccf1 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 17 Jun 2015 16:01:44 -0400 Subject: [PATCH] Fix crash initializing GlobalPrefsDialog for special case of undefined temp... ... directory at startup time. --- src/AudacityApp.cpp | 8 ++++++-- src/prefs/PrefsDialog.cpp | 9 ++------- src/prefs/PrefsDialog.h | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 90ea7c794..4a9e63021 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -92,6 +92,7 @@ It handles initialization and termination by subclassing wxApp. #include "ondemand/ODManager.h" #include "commands/Keyboard.h" #include "widgets/ErrorDialog.h" +#include "prefs/DirectoriesPrefs.h" //temporarilly commented out till it is added to all projects //#include "Profiler.h" @@ -1605,8 +1606,11 @@ bool AudacityApp::InitTempDir() // Failed wxMessageBox(_("Audacity could not find a place to store temporary files.\nPlease enter an appropriate directory in the preferences dialog.")); - GlobalPrefsDialog dialog(NULL); - dialog.ShowTempDirPage(); + // Only want one page of the preferences + DirectoriesPrefsFactory directoriesPrefsFactory; + PrefsDialog::Factories factories; + factories.push_back(&directoriesPrefsFactory); + GlobalPrefsDialog dialog(NULL, factories); dialog.ShowModal(); wxMessageBox(_("Audacity is now going to exit. Please launch Audacity again to use the new temporary directory.")); diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index 32da41f8f..71a63fe5b 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -386,18 +386,13 @@ void PrefsDialog::SelectPageByName(wxString pageName) } } -void PrefsDialog::ShowTempDirPage() -{ - SelectPageByName(_("Directories")); -} - int PrefsDialog::GetSelectedPage() const { return mCategories->GetSelection(); } -GlobalPrefsDialog::GlobalPrefsDialog(wxWindow * parent) - : PrefsDialog(parent, _("Preferences: "), DefaultFactories()) +GlobalPrefsDialog::GlobalPrefsDialog(wxWindow * parent, Factories &factories) + : PrefsDialog(parent, _("Preferences: "), factories) { } diff --git a/src/prefs/PrefsDialog.h b/src/prefs/PrefsDialog.h index 239eb4d8a..a4b468921 100644 --- a/src/prefs/PrefsDialog.h +++ b/src/prefs/PrefsDialog.h @@ -58,7 +58,6 @@ class PrefsDialog:public wxDialog void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree void SelectPageByName(wxString pageName); - void ShowTempDirPage(); // Accessor to help implementations of SavePreferredPage(), // such as by saving a preference after DoModal() returns @@ -85,7 +84,7 @@ private: class GlobalPrefsDialog : public PrefsDialog { public: - GlobalPrefsDialog(wxWindow * parent); + GlobalPrefsDialog(wxWindow * parent, Factories &factories = DefaultFactories()); virtual ~GlobalPrefsDialog(); virtual long GetPreferredPage(); virtual void SavePreferredPage();