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)
{
wxString msgTitle;
if (!wxTheApp->GetAppName().empty())
msgTitle = wxTheApp->GetAppName();
else
msgTitle = wxString(_("File error"));
#if wxUSE_STD_IOSTREAM
wxSTD ifstream store(file.mb_str());
if (store.fail() || store.bad())
if (!store.fail() && !store.bad())
#else
wxFileInputStream store(file);
if (store.GetLastError() != wxSTREAM_NO_ERROR)
if (store.GetLastError() == wxSTREAM_NO_ERROR)
#endif
{
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return false;
}
#if wxUSE_STD_IOSTREAM
LoadObject(store);
if ( !store && !store.eof() )
LoadObject(store);
if ( !!store || store.eof() )
#else
int res = LoadObject(store).GetLastError();
if ((res != wxSTREAM_NO_ERROR) &&
(res != wxSTREAM_EOF))
int res = LoadObject(store).GetLastError();
if ( res == wxSTREAM_NO_ERROR || res == wxSTREAM_EOF )
#endif
{
(void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK|wxICON_EXCLAMATION,
GetDocumentWindow());
return false;
return true;
}
return true;
wxLogError(_("Sorry, could not open this file."));
return false;
}