Re: Cannot unregister routed event handler (v2.0.1f1, C++)
Oh! This is great! Thanks for sharing this workaround, it will be helpful for more people.
Re: Cannot unregister routed event handler (v2.0.1f1, C++)
Unfortunately I found a flaw in the workaround. This is due to the nature of rxcpp.
Difficult to explain unless you are familiar with rxcpp. But let me try ...
There are cases where the line
initiate the observable's unsubscription, which calls the following lines (lambda passed to subscriber.add())
When the lambda returned, rxcpp removed it from its internal structure, resulting the captured 'wrapper' shared pointer is destroyed.
Because of it, when the line subscriber.on_next(param) returned, its lambda container 'wrapper' has already gone, crashing the program.
So, I think I still really need NoesisGUI to allow us to store lambda or std::function for Event delegates...
Difficult to explain unless you are familiar with rxcpp. But let me try ...
There are cases where the line
Code: Select all
subscriber.on_next(param);
Code: Select all
subscriber.add([_ev, wrapper]() {
// In the event of unsubscribe, remove the callback from the NoesisGUI event
auto ev = const_cast<C<Delegate<Ret(Args...)>> &>(_ev);
ev -= MakeDelegate(wrapper.get(), &FunctorToDelegate<Ret, Args...>::Invoke);
});
Because of it, when the line subscriber.on_next(param) returned, its lambda container 'wrapper' has already gone, crashing the program.
So, I think I still really need NoesisGUI to allow us to store lambda or std::function for Event delegates...
Re: Cannot unregister routed event handler (v2.0.1f1, C++)
Thanks for the detailed explanation. And yes, we undoubtedly need to solve the issue with the fixed limit in our delegates.
Who is online
Users browsing this forum: edgy-sphere and 1 guest