git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55873
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
bool wxDocument::DoSaveDocument(const wxString& file)
{
bool wxDocument::DoSaveDocument(const wxString& file)
{
- wxString msgTitle;
- if (!wxTheApp->GetAppDisplayName().empty())
- msgTitle = wxTheApp->GetAppDisplayName();
- else
- msgTitle = wxString(_("File error"));
-
#if wxUSE_STD_IOSTREAM
wxSTD ofstream store(file.mb_str(), wxSTD ios::binary);
if (store.fail() || store.bad())
#if wxUSE_STD_IOSTREAM
wxSTD ofstream store(file.mb_str(), wxSTD ios::binary);
if (store.fail() || store.bad())
if (store.GetLastError() != wxSTREAM_NO_ERROR)
#endif
{
if (store.GetLastError() != wxSTREAM_NO_ERROR)
#endif
{
- (void)wxMessageBox(_("Sorry, could not open this file for saving."), msgTitle, wxOK | wxICON_EXCLAMATION,
- GetDocumentWindow());
- // Saving error
+ wxLogError(_("File \"%s\" could not be opened for writing."), file);
if (!SaveObject(store))
{
if (!SaveObject(store))
{
- (void)wxMessageBox(_("Sorry, could not save this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
- GetDocumentWindow());
- // Saving error
+ wxLogError(_("Failed to save document to the file \"%s\"."), file);
{
#if wxUSE_STD_IOSTREAM
wxSTD ifstream store(file.mb_str(), wxSTD ios::binary);
{
#if wxUSE_STD_IOSTREAM
wxSTD ifstream store(file.mb_str(), wxSTD ios::binary);
- if (!store.fail() && !store.bad())
+ if ( store.fail() || store.bad() )
#else
wxFileInputStream store(file);
#else
wxFileInputStream store(file);
- if (store.GetLastError() == wxSTREAM_NO_ERROR)
+ if (store.GetLastError() != wxSTREAM_NO_ERROR)
+ wxLogError(_("File \"%s\" could not be opened for reading."), file);
+ return false;
+ }
+
- LoadObject(store);
- if ( !!store || store.eof() )
+ LoadObject(store);
+ if ( store.fail() || store.bad() )
- 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 )
+ {
+ wxLogError(_("Failed to read document from the file \"%s\"."), file);
+ return false;
- wxLogError(_("Sorry, could not open this file."));
- return false;