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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user