]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/file.cpp
Fix wxGrid editors background painting.
[wxWidgets.git] / src / common / file.cpp
index b2cd1bed5f6a0ff54889792d1773bd8c6bf97f47..f9badf53953e01b49bf63101b2c546f9515fe950 100644 (file)
@@ -295,7 +295,7 @@ bool wxFile::ReadAll(wxString *str, const wxMBConv& conv)
 {
     wxCHECK_MSG( str, false, wxS("Output string must be non-NULL") );
 
-    size_t length = wx_truncate_cast(size_t, Length());
+    ssize_t length = Length();
     wxCHECK_MSG( (wxFileOffset)length == Length(), false, wxT("huge file not supported") );
 
     wxCharBuffer buf(length);
@@ -309,6 +309,10 @@ bool wxFile::ReadAll(wxString *str, const wxMBConv& conv)
             return false;
 
         p += nread;
+        if ( length <= nread )
+            break;
+
+        length -= nread;
     }
 
     *p = 0;