From 7112c07abf96405677a0a75d42baf8a7f34f21c2 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Mon, 12 Oct 2015 14:06:16 +0200 Subject: [PATCH] debug dyn event handle clearing --- Tests/GOLIBTests.cs | 4 ++-- src/GraphicObjects/GraphicObject.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) 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 (); } } } -- 2.47.3