]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/stc.cpp
added wxBU_EXACTFIT
[wxWidgets.git] / src / stc / stc.cpp
index d4fbcec50ccceca291efb7d6197645da14722e82..c437fee5a0aa6687daaebc2199c32acec0487521 100644 (file)
@@ -2093,23 +2093,29 @@ bool wxStyledTextCtrl::SaveFile(const wxString& filename)
 
 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
 {
+    bool success = false;
     wxFile file(filename, wxFile::read);
 
-    if (!file.IsOpened())
-        return FALSE;
-
-    wxString contents;
-    off_t len = file.Length();
-
-    wxChar *buf = contents.GetWriteBuf(len);
-    bool success = (file.Read(buf, len) == len);
-    contents.UngetWriteBuf();
-
-    if (success)
+    if (file.IsOpened())
     {
-        SetText(contents);
-        EmptyUndoBuffer();
-        SetSavePoint();
+        wxString contents;
+        off_t len = file.Length();
+
+        if (len > 0)
+        {
+            wxChar *buf = contents.GetWriteBuf(len);
+            success = (file.Read(buf, len) == len);
+            contents.UngetWriteBuf();
+        }
+        else
+            success = true;            // empty file is ok
+
+        if (success)
+        {
+            SetText(contents);
+            EmptyUndoBuffer();
+            SetSavePoint();
+        }
     }
 
     return success;