@@ -83,7 +83,7 @@ wxBEGIN_EVENT_TABLE(Application, wxApp) EVT_TIMER(wxID_ANY, Application::OnSplas
8383
8484 // Process command line arguments, if any.
8585 for (int i = 1 ; i < argc; i++) {
86- const AppLoadResult result = LoadFile (argv[i]);
86+ const AppLoadResult result = LoadFile (argv[i], nullptr );
8787 if (result == GBT_APP_OPEN_FAILED) {
8888 wxMessageBox (wxString::Format (_ (" Gambit could not open file for reading:\n %s" ), argv[i]),
8989 _ (" Unable to open file" ), wxOK | wxICON_ERROR, nullptr );
@@ -131,10 +131,12 @@ void Application::DismissSplash()
131131 m_splash = nullptr ;
132132}
133133
134- AppLoadResult Application::LoadFile (const wxString &p_filename)
134+ AppLoadResult Application::LoadFile (const wxString &p_filename, wxWindow *p_parent )
135135{
136- std::ifstream infile (( const char *) p_filename.mb_str ());
136+ std::ifstream infile (p_filename.mb_str ());
137137 if (!infile.good ()) {
138+ wxMessageBox (_ (" Gambit could not open file for reading:\n " ) + p_filename,
139+ _ (" Unable to open file" ), wxOK | wxICON_ERROR, p_parent);
138140 return GBT_APP_OPEN_FAILED;
139141 }
140142
@@ -146,21 +148,21 @@ AppLoadResult Application::LoadFile(const wxString &p_filename)
146148 (void )new GameFrame (nullptr , doc);
147149 return GBT_APP_FILE_OK;
148150 }
149- else {
150- delete doc;
151- }
151+ delete doc;
152152
153153 try {
154154 const Game nfg = ReadGame (infile);
155155
156156 m_fileHistory.AddFileToHistory (p_filename);
157157 m_fileHistory.Save (*wxConfigBase::Get ());
158158 doc = new GameDocument (nfg);
159- doc->SetFilename (wxT ( " " ) );
159+ doc->SetFilename (" " );
160160 (void )new GameFrame (nullptr , doc);
161161 return GBT_APP_FILE_OK;
162162 }
163163 catch (InvalidFileException &) {
164+ wxMessageBox (_ (" File is not in a format Gambit recognizes:\n " ) + p_filename,
165+ _ (" Unable to read file" ), wxOK | wxICON_ERROR, p_parent);
164166 return GBT_APP_PARSE_FAILED;
165167 }
166168}
0 commit comments