Set wxTextAreaBase::m_filename in the methods of this class itself.
m_filename member was declared in wxTextAreaBase but set only in the overridden wxTextCtrlBase methods. This meant that it wasn't updated correctly in wxStyledTextCtrl which also derives from wxTextAreaBase and so saving SaveFile() with empty file name didn't work there even when the control had been originally loaded from a file. Move the code updating m_filename to wxTextAreaBase itself to fix this. This also simplifies the code as it's now not necessary to override Do{Load,Save}File() in wxTextCtrlBase at all. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -743,9 +743,6 @@ protected:
|
|||||||
int overflow(int i);
|
int overflow(int i);
|
||||||
#endif // wxHAS_TEXT_WINDOW_STREAM
|
#endif // wxHAS_TEXT_WINDOW_STREAM
|
||||||
|
|
||||||
virtual bool DoLoadFile(const wxString& file, int fileType);
|
|
||||||
virtual bool DoSaveFile(const wxString& file, int fileType);
|
|
||||||
|
|
||||||
// Another wxTextAreaBase override.
|
// Another wxTextAreaBase override.
|
||||||
virtual bool IsValidPosition(long pos) const
|
virtual bool IsValidPosition(long pos) const
|
||||||
{
|
{
|
||||||
|
@@ -851,23 +851,16 @@ bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)
|
|||||||
{
|
{
|
||||||
SetValue(text);
|
SetValue(text);
|
||||||
|
|
||||||
|
DiscardEdits();
|
||||||
|
m_filename = filename;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_FFILE
|
#endif // wxUSE_FFILE
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int fileType)
|
|
||||||
{
|
|
||||||
if ( wxTextAreaBase::DoLoadFile(filename, fileType) )
|
|
||||||
{
|
|
||||||
DiscardEdits();
|
|
||||||
m_filename = filename;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
wxLogError(_("File couldn't be loaded."));
|
wxLogError(_("File couldn't be loaded."));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -875,10 +868,19 @@ bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)
|
|||||||
{
|
{
|
||||||
#if wxUSE_FFILE
|
#if wxUSE_FFILE
|
||||||
wxFFile file(filename, wxT("w"));
|
wxFFile file(filename, wxT("w"));
|
||||||
return file.IsOpened() && file.Write(GetValue(), *wxConvCurrent);
|
if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) )
|
||||||
#else
|
{
|
||||||
return false;
|
// if it worked, save for future calls
|
||||||
|
m_filename = filename;
|
||||||
|
|
||||||
|
// it's not modified any longer
|
||||||
|
DiscardEdits();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endif // wxUSE_FFILE
|
#endif // wxUSE_FFILE
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType)
|
bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType)
|
||||||
@@ -895,21 +897,6 @@ bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType)
|
|||||||
return DoSaveFile(filenameToUse, fileType);
|
return DoSaveFile(filenameToUse, fileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int fileType)
|
|
||||||
{
|
|
||||||
if ( wxTextAreaBase::DoSaveFile(filename, fileType) )
|
|
||||||
{
|
|
||||||
// if it worked, save for future calls
|
|
||||||
m_filename = filename;
|
|
||||||
|
|
||||||
// it's not modified any longer
|
|
||||||
DiscardEdits();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// stream-like insertion operator
|
// stream-like insertion operator
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user