Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toast notification always posting the click event on MSW #24341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/msw/rt/notifmsgrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,31 @@ wxString wxToastNotifMsgImpl::ms_appId;
wxCOMPtr<IToastNotificationManagerStatics> wxToastNotifMsgImpl::ms_toastMgr;

HRESULT wxToastEventHandler::Invoke(
IToastNotification *WXUNUSED(sender),
IInspectable *WXUNUSED(args))
IToastNotification *sender,
IInspectable *args)
{
if ( m_impl )
{
wxCommandEvent evt(wxEVT_NOTIFICATION_MESSAGE_CLICK);
m_impl->ProcessNotificationEvent(evt);
IToastDismissedEventArgs *dea = nullptr;
IToastFailedEventArgs *fea = nullptr;

if ( SUCCEEDED(args->QueryInterface(__uuidof(IToastDismissedEventArgs), (void**)&dea)) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to call Release() on dea in case of success to avoid memory leaks (and the same for fea below, of course).

{
// FIXME: We have for some unknown reason ended up in this function even though
// args is really a IToastDismissedEventArgs*. Call the actual implementation
// we wanted.
return Invoke(sender, dea);
}
else if ( SUCCEEDED(args->QueryInterface(__uuidof(IToastFailedEventArgs), (void**)&fea)) )
{
// FIXME: Same as above.
return Invoke(sender, fea);
}
else
{
wxCommandEvent evt(wxEVT_NOTIFICATION_MESSAGE_CLICK);
m_impl->ProcessNotificationEvent(evt);
}
}

return S_OK;
Expand Down
Loading