[Mono-bugs] [Bug 80994][Maj] Changed - NullReferenceExeption inside RichTextBox

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Mar 18 23:44:01 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by georgegiolfan at yahoo.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80994

--- shadow/80994	2007-03-18 21:02:54.000000000 -0500
+++ shadow/80994.tmp.7434	2007-03-18 22:44:01.000000000 -0500
@@ -1,13 +1,13 @@
 Bug#: 80994
 Product: Mono: Class Libraries
 Version: 1.2
 OS: Windows XP
 OS Details: Service Pack 2
-Status: RESOLVED   
-Resolution: FIXED
+Status: REOPENED   
+Resolution: 
 Severity: Unknown
 Priority: Major
 Component: Windows.Forms
 AssignedTo: jackson at ximian.com                            
 ReportedBy: linux.sarge at gmail.com               
 QAContact: mono-bugs at ximian.com
@@ -137,6 +137,38 @@
 
 Will this fix be included in the next release? This bug made some of
 my programs incompatible with mono.
 
 ------- Additional Comments From jackson at ximian.com  2007-03-18 21:02 -------
 This bug is now fixed in SVN.  Thanks for the report.
+
+------- Additional Comments From georgegiolfan at yahoo.com  2007-03-18 22:44 -------
+Since I don't completely understand the code in TextControl.cs, 
+TextBoxBase.cs, etc., I may be wrong.
+
+While the bug is technically fixed (no more NullReferenceExeption), 
+the fix avoids the real problem. This has nothing to do with the 
+selection length. The problem is that, in the SelectionFont getter, 
+document.selection_start.tag has a wrong value. This is caused by the 
+fact that, in the SelectionFont setter, the same logic is used to set 
+both document.selection_start.tag and document.selection_end.tag. 
+This is wrong to be because when the selection starts between tags 
+the first tag in the selection is the one after the selection start 
+(as opposed to the last tag in the selection, which would be the one 
+before the selection end, if the selection ends between tags). So my 
+previous patch works only in this case.
+Here is test (if you want to have a NullReferenceException, change 
+SelectionLength = 1 to SelectionLength = 2).
+using System.Diagnostics;
+using System.Drawing;
+using System.Windows.Forms;
+class Test {
+	static void Main() {
+		RichTextBox t = new RichTextBox();
+		t.Text = "123";
+		t.SelectionStart = 1;
+		t.SelectionLength = 1;
+		Font f = new Font(FontFamily.GenericMonospace, 123);
+		t.SelectionFont = f;
+		Debug.Assert(t.SelectionFont.Size == f.Size);
+	}
+}


More information about the mono-bugs mailing list