use wxLogError() instead of wxMessageBox in wxDocument::DoOpenDocument(), otherwise the error message don't appear in correct order

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-07-14 16:13:19 +00:00
parent 7f54e70f17
commit 64c12a6d55

View File

@@ -596,39 +596,26 @@ bool wxDocument::DoSaveDocument(const wxString& file)
bool wxDocument::DoOpenDocument(const wxString& file) bool wxDocument::DoOpenDocument(const wxString& file)
{ {
wxString msgTitle;
if (!wxTheApp->GetAppName().empty())
msgTitle = wxTheApp->GetAppName();
else
msgTitle = wxString(_("File error"));
#if wxUSE_STD_IOSTREAM #if wxUSE_STD_IOSTREAM
wxSTD ifstream store(file.mb_str()); wxSTD ifstream store(file.mb_str());
if (store.fail() || store.bad()) if (!store.fail() && !store.bad())
#else #else
wxFileInputStream store(file); wxFileInputStream store(file);
if (store.GetLastError() != wxSTREAM_NO_ERROR) if (store.GetLastError() == wxSTREAM_NO_ERROR)
#endif #endif
{ {
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return false;
}
#if wxUSE_STD_IOSTREAM #if wxUSE_STD_IOSTREAM
LoadObject(store); LoadObject(store);
if ( !store && !store.eof() ) if ( !!store || store.eof() )
#else #else
int res = LoadObject(store).GetLastError(); int res = LoadObject(store).GetLastError();
if ((res != wxSTREAM_NO_ERROR) && if ( res == wxSTREAM_NO_ERROR || res == wxSTREAM_EOF )
(res != wxSTREAM_EOF))
#endif #endif
{ return true;
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return false;
} }
return true; wxLogError(_("Sorry, could not open this file."));
return false;
} }