Re: Caliburn.Noesis (Caliburn.Micro port)
Posted: 14 Jan 2025, 22:36
I'm having an issue with this code:
This is the changed event handler of a DependencyProperty. As soon as the handler is executed and is trying to access the closure
Unity crashes. Is there an issue with capturing the DependencyPropertyChangedEventArgs like this? is it crashing because the native pointer has become invalid?
Edit: I've tested this. If I change the code so I cache e.NewValue in a variable and instead do this in the lamda:
it works. So this might be a problem. DependencyPropertyChangedEventArgs are not capturable in a closure? I can work around it in this case, but I need to dig through the code whether this is done anywhere else.
I think this is a bug. I reported it.
https://www.noesisengine.com/bugs/view.php?id=3901
Code: Select all
static void ModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (View.InDesignMode || object.ReferenceEquals(e.NewValue, e.OldValue))
{
return;
}
var fe = d as FrameworkElement;
if (fe == null)
{
return;
}
View.ExecuteOnLoad(fe, delegate
{
var target = e.NewValue;
d.SetValue(View.IsScopeRootProperty, true);
var context = string.IsNullOrEmpty(fe.Name)
? fe.GetHashCode().ToString()
: fe.Name;
ViewModelBinder.Bind(target, d, context);
});
}Code: Select all
var target = e.NewValue;Edit: I've tested this. If I change the code so I cache e.NewValue in a variable and instead do this in the lamda:
Code: Select all
var target = newValue;I think this is a bug. I reported it.
https://www.noesisengine.com/bugs/view.php?id=3901