-
Notifications
You must be signed in to change notification settings - Fork 263
Description
As can be seen here, the hresult return is ignored:
cppwinrt/strings/base_events.h
Lines 57 to 63 in 7e730e7
| void revoke() noexcept | |
| { | |
| if (I object = std::exchange(m_object, {}).get()) | |
| { | |
| ((*reinterpret_cast<impl::abi_t<I>**>(&object))->*(m_method))(m_token); | |
| } | |
| } |
However, in the code generated for manual unregistration, the return value is asserted to be S_OK:
cppwinrt/cppwinrt/code_writers.h
Lines 1121 to 1128 in 4366357
| if (is_noexcept(method)) | |
| { | |
| format = R"( template <typename D%> WINRT_IMPL_AUTO(%) consume_%<D%>::%(%) const noexcept | |
| {% | |
| WINRT_VERIFY_(0, WINRT_IMPL_SHIM(%)->%(%));% | |
| } | |
| )"; | |
| } |
This means that the behavior is different: I was migrating code to use manual unregistration because it was already holding a strong reference so storing a single event_token takes much less storage. While event_revoker worked fine, manual unregistration triggers the assert if the RPC server has died while trying to unregister the callback (because then the method to unregister the callback returns RPC_S_SERVER_UNAVAILABLE).