Hopefully fix crash on startup on Windows.
authorCarl Hetherington <cth@carlh.net>
Wed, 5 Jun 2013 13:28:27 +0000 (14:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 5 Jun 2013 13:28:27 +0000 (14:28 +0100)
src/wx/new_film_dialog.cc
src/wx/new_film_dialog.h

index 737b07fbb58a591e62887cc12af75bb4075cead0..191482a7cbcdb23ca3da8f48720dbbcdc7bf2d06 100644 (file)
@@ -29,7 +29,7 @@
 using namespace std;
 using namespace boost;
 
-string NewFilmDialog::_directory = Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()));
+boost::optional<string> NewFilmDialog::_directory;
 
 NewFilmDialog::NewFilmDialog (wxWindow* parent)
        : wxDialog (parent, wxID_ANY, _("New Film"))
@@ -51,7 +51,12 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent)
 #else  
        _folder = new wxDirPickerCtrl (this, wxDD_DIR_MUST_EXIST);
 #endif
-       _folder->SetPath (std_to_wx (_directory));
+
+       if (!_directory) {
+               _directory = Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()));
+       }
+       
+       _folder->SetPath (std_to_wx (_directory.get()));
        table->Add (_folder, 1, wxEXPAND);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
index 715f71f516f309d9db14b9761c40ef9b348f7591..bfcbd423c2cb31a3cc60a9a07bfbc15ab8ad7e17 100644 (file)
@@ -37,5 +37,5 @@ private:
 #else
        wxDirPickerCtrl* _folder;
 #endif
-       static std::string _directory;
+       static boost::optional<std::string> _directory;
 };