Author: gert
Date: 2007-04-29 04:13:50 -0400 (Sun, 29 Apr 2007)
New Revision: 76444
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
Log:
* RichTextBox.cs: In LoadFile, use StreamReader to read plain text.
Fixes bug #81479. Include details of exception when LoadFile fails.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-29 08:05:47 UTC (rev 76443)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-04-29 08:13:50 UTC (rev 76444)
@@ -1,3 +1,8 @@
+2007-04-29 Gert Driesen <[EMAIL PROTECTED]>
+
+ * RichTextBox.cs: In LoadFile, use StreamReader to read plain text.
+ Fixes bug #81479. Include details of exception when LoadFile fails.
+
2007-04-28 Alan McGovern <[EMAIL PROTECTED]>
* DrawListViewSubItemEventArgs.cs: Added missing setter
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2007-04-29 08:05:47 UTC (rev 76443)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/RichTextBox.cs
2007-04-29 08:13:50 UTC (rev 76444)
@@ -876,21 +876,21 @@
// FIXME - ignoring unicode
if (fileType == RichTextBoxStreamType.PlainText) {
- StringBuilder sb;
- int count;
- byte[] buffer;
+ StringBuilder sb;
+ char[] buffer;
try {
- sb = new
StringBuilder((int)data.Length);
- buffer = new byte[1024];
+ sb = new StringBuilder ((int)
data.Length);
+ buffer = new char [1024];
} catch {
throw new IOException("Not enough
memory to load document");
}
- count = 0;
- while (count < data.Length) {
- count += data.Read(buffer, count, 1024);
- sb.Append(buffer);
+ StreamReader sr = new StreamReader (data,
Encoding.Default, true);
+ int charsRead = sr.Read (buffer, 0,
buffer.Length);
+ while (charsRead > 0) {
+ sb.Append (buffer, 0, charsRead);
+ charsRead = sr.Read (buffer, 0,
buffer.Length);
}
base.Text = sb.ToString();
return;
@@ -924,8 +924,8 @@
LoadFile(data, fileType);
}
#if !DEBUG
- catch {
- throw new IOException("Could not open file " +
path);
+ catch (Exception ex) {
+ throw new IOException("Could not open file " +
path, ex);
}
#endif
finally {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches