diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-14 18:46:08 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-14 18:46:08 +0200 |
| commit | 475b4dc3ea6354474349c9408fe03cc53b946d8a (patch) | |
| tree | 13478e4479b1a34fc57bbf830096e032d936a6ed /src | |
| parent | 01ec9f5a3fa94df22844e22f47cd4853959fe99e (diff) | |
ensure eventInfo is not null (could be null for propertyLess bindings)
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index c9f7a39f..c3c22e7b 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -934,22 +934,24 @@ namespace go /// and delete ref of this in Shared interface refs
/// </summary>
public virtual void ClearBinding(){
- if (this.DataSource == null)
- return;
object ds = this.DataSource;
+ if (ds == null)
+ return;
+
Type dataSourceType = ds.GetType ();
EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");
- FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");
- MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;
- if (multicastDelegate != null){
- foreach (Delegate d in multicastDelegate.GetInvocationList())
- {
- string dn = d.Method.Name;
- if (!dn.StartsWith ("dynHandle_"))
- continue;
- int did = int.Parse (dn.Substring (10));
- if (this.DynamicMethodIds.Contains(did))
- evtInfo.RemoveEventHandler (ds, d);
+ if (evtInfo != null) {
+ FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");
+ MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;
+ if (multicastDelegate != null) {
+ foreach (Delegate d in multicastDelegate.GetInvocationList()) {
+ string dn = d.Method.Name;
+ if (!dn.StartsWith ("dynHandle_"))
+ continue;
+ int did = int.Parse (dn.Substring (10));
+ if (this.DynamicMethodIds.Contains (did))
+ evtInfo.RemoveEventHandler (ds, d);
+ }
}
}
|