]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datstrm.cpp
forced redraw before scrolling
[wxWidgets.git] / src / common / datstrm.cpp
index 5c4fd46091807f4a169209053ec3579403eb6091..e0bd854d4cbfb81db6eab43437e6358956c96fd5 100644 (file)
@@ -90,19 +90,23 @@ wxString wxDataInputStream::ReadString()
 
   len = Read32();
 
+  if (len > 0)
+  {
 #if wxUSE_UNICODE
-  char *tmp = new char[len + 1];
-  m_input->Read(tmp, len);
-  tmp[len] = 0;
-  wxString s(tmp);
-  delete[] tmp;
+    char *tmp = new char[len + 1];
+    m_input->Read(tmp, len);
+    tmp[len] = 0;
+    wxString s(tmp);
+    delete[] tmp;
 #else
-  wxString s;
-  m_input->Read(s.GetWriteBuf(len), len);
-  s.UngetWriteBuf();
+    wxString s;
+    m_input->Read(s.GetWriteBuf(len), len);
+    s.UngetWriteBuf();
 #endif
-
-  return s;
+    return s;
+  }
+  else
+    return wxEmptyString;
 }
 
 wxDataInputStream& wxDataInputStream::operator>>(wxString& s)
@@ -203,8 +207,9 @@ void wxDataOutputStream::Write8(wxUint8 i)
 void wxDataOutputStream::WriteString(const wxString& string)
 {
   const wxWX2MBbuf buf = string.mb_str();
-  Write32(string.Length());
-  m_output->Write(buf, string.Len());
+  Write32(string.Len());
+  if (string.Len() > 0)
+      m_output->Write(buf, string.Len());
 }
 
 // Must be at global scope for VC++ 5
@@ -232,7 +237,7 @@ wxDataOutputStream& wxDataOutputStream::operator<<(const wxChar *string)
   return *this;
 }
 
-wxDataOutputStream& wxDataOutputStream::operator<<(wxString& string)
+wxDataOutputStream& wxDataOutputStream::operator<<(const wxString& string)
 {
   WriteString(string);
   return *this;