Skip to content

event_revoker ignores errors while manual unregistration does not #1003

@sylveon

Description

@sylveon

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions