From: jpbruyere Date: Mon, 12 Oct 2015 12:06:16 +0000 (+0200) Subject: debug dyn event handle clearing X-Git-Tag: 0.3~111 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=7112c07abf96405677a0a75d42baf8a7f34f21c2;p=jp%2Fcrow.git debug dyn event handle clearing --- diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 508acc2d..13576b24 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -44,8 +44,8 @@ namespace test "testSpinner.goml", "testPopper.goml", "testGroupBox.goml", -// "testWindow.goml", -// "testMsgBox.goml", + "testWindow.goml", + "testMsgBox.goml", "testGrid.goml", "testMeter.goml", // "testCombobox.goml", diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 505e85a9..6e2d726c 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1285,16 +1285,22 @@ namespace go foreach (Binding b in Bindings) { if (string.IsNullOrEmpty (b.DynMethodId)) continue; - Type dataSourceType = b.Target.Instance.GetType (); + MemberReference mr = null; + if (b.Target == null) + mr = b.Source; + else + mr = b.Target; + Type dataSourceType = mr.Instance.GetType(); EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged"); FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged"); - MulticastDelegate multicastDelegate = evtFi.GetValue (b.Target.Instance) as MulticastDelegate; + MulticastDelegate multicastDelegate = evtFi.GetValue (mr.Instance) as MulticastDelegate; if (multicastDelegate != null) { foreach (Delegate d in multicastDelegate.GetInvocationList()) { if (d.Method.Name == b.DynMethodId) - evtInfo.RemoveEventHandler (b.Target.Instance, d); + evtInfo.RemoveEventHandler (mr.Instance, d); } } + b.Reset (); } } }