From 64c12a6d559c20e495d1ad79b7a6fb547d9cc7b1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 14 Jul 2005 16:13:19 +0000 Subject: [PATCH] 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 --- src/common/docview.cpp | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 221ce1b..ce47e57 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -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; } -- 2.7.4