As can be seen here, the hresult return is ignored:
|
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:
|
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).
As can be seen here, the
hresultreturn is ignored:cppwinrt/strings/base_events.h
Lines 57 to 63 in 7e730e7
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
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_tokentakes much less storage. Whileevent_revokerworked 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 returnsRPC_S_SERVER_UNAVAILABLE).