]> O.S.I.I.S - jp/crow.git/commitdiff
ensure eventInfo is not null (could be null for propertyLess bindings)
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 14 Sep 2015 16:46:08 +0000 (18:46 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 14 Sep 2015 16:46:08 +0000 (18:46 +0200)
src/GraphicObjects/GraphicObject.cs

index c9f7a39fa4be19d49b1583feacb1999deea882da..c3c22e7b6b25c7b4e2a5ecb0b33a8837cec3a176 100644 (file)
@@ -934,22 +934,24 @@ namespace go
                ///  and delete ref of this in Shared interface refs\r
                /// </summary>\r
                public virtual void ClearBinding(){\r
-                       if (this.DataSource == null)\r
-                               return;\r
                        object ds = this.DataSource;\r
+                       if (ds == null)\r
+                               return;\r
+                       \r
                        Type dataSourceType = ds.GetType ();\r
                        EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");\r
-                       FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");\r
-                       MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;\r
-                       if (multicastDelegate != null){                         \r
-                               foreach (Delegate d in multicastDelegate.GetInvocationList())\r
-                               {\r
-                                       string dn = d.Method.Name;\r
-                                       if (!dn.StartsWith ("dynHandle_"))\r
-                                               continue;\r
-                                       int did = int.Parse (dn.Substring (10));\r
-                                       if (this.DynamicMethodIds.Contains(did))\r
-                                               evtInfo.RemoveEventHandler (ds, d);\r
+                       if (evtInfo != null) {\r
+                               FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");\r
+                               MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;\r
+                               if (multicastDelegate != null) {                                \r
+                                       foreach (Delegate d in multicastDelegate.GetInvocationList()) {\r
+                                               string dn = d.Method.Name;\r
+                                               if (!dn.StartsWith ("dynHandle_"))\r
+                                                       continue;\r
+                                               int did = int.Parse (dn.Substring (10));\r
+                                               if (this.DynamicMethodIds.Contains (did))\r
+                                                       evtInfo.RemoveEventHandler (ds, d);\r
+                                       }\r
                                }\r
                        }\r
                                \r