DependencyProperty.UnsetValue is not recreated after reinitialization
aienabled opened this issue · 2 comments
Hi guys,
after upgrading from 3.0.12 to 3.2.1 I've noticed a major issue: DataTriggers stops working after NoesisGUI reinitialization (Shutdown and then Init). After debugging I have found out that the DependencyProperty.UnsetValue
object is disposed (swigCPtr.Handle equals zero) so DataTrigger comparison returns incorrect result.
As I see, two years ago in 3.1.0 you've made an optimization by creating the DependencyProperty.UnsetValue
object only once. Now I realize why 3.1.0 was broken for me among some other issues (so I've skipped it).
I've made a straightforward fix like this:
private static NamedObject unsetValue;
public static object UnsetValue
{
get
{
if (unsetValue is null
|| ((NamedObject)unsetValue).IsDisposed)
{
unsetValue = new NamedObject("DependencyProperty.UnsetValue", UnsetValuePtr);
}
return unsetValue;
}
}
However I'm not sure if it's a valid fix as there could be other cases where a similar issue may appear.
I've found the same issue with Binding.DoNothing
Regards!
Vladimir
Hi Vladimir, I think your change is safe and we are going to integrate it.
Thanks a lot for reporting and providing the patch!
Already fixed and included in latest release