]> O.S.I.I.S - jp/crow.git/commitdiff
debug remove old binding from ds
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 18 Jan 2017 14:23:43 +0000 (15:23 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 18 Jan 2017 14:23:43 +0000 (15:23 +0100)
src/Instantiator.cs

index 6aaa7483b8252d0b8c9ef20ed3dabd0bf0db827f..db0bd353bf122a3d5ee3ef58c919482d7f9f8e6f 100644 (file)
@@ -822,7 +822,7 @@ namespace Crow
                        //the actual value of the origin member of the datasource and then will bind the value changed
                        //dyn methode.
                        //dm is bound to the instanciator instance to have access to cached dyn meth and delegates
-                       dm = new DynamicMethod ("dyn_dschanged",
+                       dm = new DynamicMethod ("dyn_dschanged" + NewId,
                                typeof (void),
                                CompilerServices.argsBoundDSChange, true);
 
@@ -846,10 +846,10 @@ namespace Crow
                                        il.Emit (OpCodes.Brfalse, cancelRemove);//old parent is null
 
                                        //remove handler
+                                       il.Emit (OpCodes.Ldarg_1);//3d arg: instance bound to delegate (the source)
+                                       il.Emit (OpCodes.Ldstr, "ValueChanged");//2nd arg event name
                                        il.Emit (OpCodes.Ldarg_2);//1st arg load old datasource
                                        il.Emit (OpCodes.Ldfld, CompilerServices.fiDSCOldDS);
-                                       il.Emit (OpCodes.Ldstr, "ValueChanged");//2nd arg event name
-                                       il.Emit (OpCodes.Ldarg_1);//3d arg: instance bound to delegate (the source)
                                        il.Emit (OpCodes.Call, CompilerServices.miRemEvtHdlByTarget);
                                        il.MarkLabel(cancelRemove);
                                }
@@ -929,6 +929,11 @@ namespace Crow
                        PropertyInfo piOrig = tOrig.GetProperty (origMember);
                        PropertyInfo piDest = tDest.GetProperty (destMember);
 
+                       if (piDest == null) {
+                               Debug.WriteLine ("Member '{0}' not found in new DataSource '{1}' of '{2}'", destMember, dest, orig);
+                               return;
+                       }
+
                        #region ValueChanged emit
                        DynamicMethod dm = new DynamicMethod ("dyn_valueChanged" + NewId,
                                typeof (void), CompilerServices.argsBoundValueChange, true);