Check that the file successfully loaded, use the length read for the conversion.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2004-03-29 20:01:16 +00:00
parent c2697b8719
commit 9efe0302c3
4 changed files with 16 additions and 8 deletions

View File

@ -2549,8 +2549,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
#if wxUSE_UNICODE
wxMemoryBuffer buffer(len+1);
success = (file.Read(buffer.GetData(), len) == len);
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent);
if (success) {
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent, len);
}
#else
wxString buffer;
success = (file.Read(wxStringBuffer(buffer, len), len) == len);

View File

@ -358,8 +358,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
#if wxUSE_UNICODE
wxMemoryBuffer buffer(len+1);
success = (file.Read(buffer.GetData(), len) == len);
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent);
if (success) {
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent, len);
}
#else
wxString buffer;
success = (file.Read(wxStringBuffer(buffer, len), len) == len);

View File

@ -2549,8 +2549,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
#if wxUSE_UNICODE
wxMemoryBuffer buffer(len+1);
success = (file.Read(buffer.GetData(), len) == len);
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent);
if (success) {
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent, len);
}
#else
wxString buffer;
success = (file.Read(wxStringBuffer(buffer, len), len) == len);

View File

@ -358,8 +358,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
#if wxUSE_UNICODE
wxMemoryBuffer buffer(len+1);
success = (file.Read(buffer.GetData(), len) == len);
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent);
if (success) {
((char*)buffer.GetData())[len] = 0;
contents = wxString(buffer, *wxConvCurrent, len);
}
#else
wxString buffer;
success = (file.Read(wxStringBuffer(buffer, len), len) == len);