Author: ivanz
Date: 2008-02-16 15:11:11 -0500 (Sat, 16 Feb 2008)
New Revision: 95915
Modified:
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
Log:
2008-02-16 Ivan N. Zlatev <[EMAIL PROTECTED]>
[Backport to 1.9]
* GridEntry.cs:
- Fix handling of a null current value.
- Swallow editor exceptions.
[Fixes bug #362114]
Modified:
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
---
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-02-16 20:07:09 UTC (rev 95914)
+++
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-02-16 20:11:11 UTC (rev 95915)
@@ -1,6 +1,14 @@
2008-02-16 Ivan N. Zlatev <[EMAIL PROTECTED]>
[Backport to 1.9]
+ * GridEntry.cs:
+ - Fix handling of a null current value.
+ - Swallow editor exceptions.
+ [Fixes bug #362114]
+
+2008-02-16 Ivan N. Zlatev <[EMAIL PROTECTED]>
+
+ [Backport to 1.9]
* PropertyGridTextBox.cs, PropertyGridView.cs: Explicitly send
a mouse down event to the textbox so that we get the caret
positioned under cursor.
Modified:
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
===================================================================
---
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
2008-02-16 20:07:09 UTC (rev 95914)
+++
branches/mono-1-9/mcs/class/Managed.Windows.Forms/System.Windows.Forms/GridEntry.cs
2008-02-16 20:11:11 UTC (rev 95915)
@@ -306,8 +306,13 @@
public UITypeEditorEditStyle EditorStyle {
get {
UITypeEditor editor = GetEditor ();
- if (editor != null)
- return editor.GetEditStyle
((ITypeDescriptorContext)this);
+ if (editor != null) {
+ try {
+ return editor.GetEditStyle
((ITypeDescriptorContext)this);
+ } catch {
+ // Some of our Editors throw
NotImplementedException
+ }
+ }
return UITypeEditorEditStyle.None;
}
}
@@ -369,7 +374,7 @@
(TypeConverter.StandardValuesCollection)
PropertyDescriptor.Converter.GetStandardValues();
if (values != null) {
for (int i = 0; i < values.Count; i++) {
- if (this.Value.Equals
(values[i])){
+ if (this.Value != null &&
this.Value.Equals (values[i])){
if (i < values.Count-1)
success =
SetValue (values[i+1], out error);
else
@@ -404,26 +409,35 @@
TypeConverter converter = PropertyDescriptor.Converter;
// if the new value is not of the same type try to
convert it
if (value != null &&
- this.Value != null && value.GetType () !=
this.Value.GetType ()) {
+ (this.Value == null ||
+ this.Value != null && value.GetType () !=
this.Value.GetType ())) {
+ bool conversionError = false;
if (converter != null &&
converter.CanConvertFrom (value.GetType
())) {
try {
value = converter.ConvertFrom
(value);
} catch {
- string valueText =
ConvertToString (value);
- if (valueText != null) {
- error = "Property value
'" + valueText + "' of '" +
-
PropertyDescriptor.Name + "' is not convertible to type '" +
-
this.Value.GetType ().Name + "'";
-
- } else {
- error = "Property value
of '" +
-
PropertyDescriptor.Name + "' is not convertible to type '" +
-
this.Value.GetType ().Name + "'";
- }
- return false;
+ conversionError = true;
}
+ } else {
+ conversionError = true;
}
+ if (conversionError) {
+ // MS swallows those
+ //
+ // string valueText = ConvertToString
(value);
+ // if (valueText != null) {
+ // error = "Property value '" +
valueText + "' of '" +
+ // PropertyDescriptor.Name
+ "' is not convertible to type '" +
+ //
this.PropertyDescriptor.PropertyType.Name + "'";
+ //
+ // } else {
+ // error = "Property value of '" +
+ // PropertyDescriptor.Name
+ "' is not convertible to type '" +
+ //
this.PropertyDescriptor.PropertyType.Name + "'";
+ // }
+ return false;
+ }
}
bool changed = false;
@@ -451,13 +465,13 @@
properties[i].SetValue
(propertyOwners[i], value);
} catch {
// MS seems to swallow
this
- //
+ //
// string valueText =
ConvertToString (value);
// if (valueText !=
null)
// error =
"Property value '" + valueText + "' of '" + properties[i].Name + "' is
invalid.";
// else
// error =
"Property value of '" + properties[i].Name + "' is invalid.";
- // return false;
+ return false;
}
if (IsValueType
(this.ParentEntry))
@@ -595,8 +609,13 @@
public virtual bool PaintValueSupported {
get {
UITypeEditor editor = GetEditor ();
- if (editor != null)
- return editor.GetPaintValueSupported ();
+ if (editor != null) {
+ try {
+ return
editor.GetPaintValueSupported ();
+ } catch {
+ // Some of our Editors throw
NotImplementedException
+ }
+ }
return false;
}
}
@@ -608,7 +627,7 @@
try {
editor.PaintValue (this.Value, gfx,
rect);
} catch {
- // TODO
+ // Some of our Editors throw
NotImplementedException
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches