summaryrefslogtreecommitdiff
path: root/plugins/Toaster/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-06-29 16:46:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-06-29 16:46:25 +0300
commit5c272fb331e50049bffda46aa120c159e983a6d7 (patch)
treee4ae6a031e85774d302c760a14e0702e45e99edf /plugins/Toaster/src
parentc053264e73a9ce72ca1ebf89c795f0939f4d74ea (diff)
Toaster: hard times need hard ways
Diffstat (limited to 'plugins/Toaster/src')
-rw-r--r--plugins/Toaster/src/services.cpp2
-rw-r--r--plugins/Toaster/src/toast_notification.cpp27
-rw-r--r--plugins/Toaster/src/toast_notification.h2
3 files changed, 18 insertions, 13 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp
index 389607d748..b70dfe253d 100644
--- a/plugins/Toaster/src/services.cpp
+++ b/plugins/Toaster/src/services.cpp
@@ -182,7 +182,7 @@ static INT_PTR HideToast(WPARAM, LPARAM lParam)
{
auto *pNotification = (ToastNotification*)lParam;
if (pNotification)
- pNotification->Hide();
+ pNotification->Destroy();
return 0;
}
diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp
index d0778ff384..1b22086b9e 100644
--- a/plugins/Toaster/src/toast_notification.cpp
+++ b/plugins/Toaster/src/toast_notification.cpp
@@ -46,6 +46,9 @@ ToastNotification::~ToastNotification()
_signature = 0;
if (_pvPopupData != nullptr)
CallPopupProc(UM_FREEPLUGINDATA);
+
+ if (notification)
+ notifier->Hide(notification.Get());
}
HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXmlDocument **xml)
@@ -99,12 +102,10 @@ HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToa
HRESULT ToastNotification::OnActivate(_In_ ABI::Windows::UI::Notifications::IToastNotification *, IInspectable *)
{
- CallPopupProc(WM_COMMAND);
- {
- mir_cslock lck(csNotifications);
- lstNotifications.remove(this);
+ if (_signature == TOAST_SIGNATURE) {
+ CallPopupProc(WM_COMMAND);
+ Destroy();
}
- delete this;
return S_OK;
}
@@ -115,7 +116,7 @@ HRESULT ToastNotification::OnDismiss(_In_ ABI::Windows::UI::Notifications::IToas
CHECKHR(e->get_Reason(&tdr));
if (tdr == ABI::Windows::UI::Notifications::ToastDismissalReason_UserCanceled)
CallPopupProc(WM_CONTEXTMENU);
- Hide();
+ Destroy();
}
return S_OK;
}
@@ -123,12 +124,16 @@ HRESULT ToastNotification::OnDismiss(_In_ ABI::Windows::UI::Notifications::IToas
HRESULT ToastNotification::OnFail(_In_ ABI::Windows::UI::Notifications::IToastNotification *, _In_ ABI::Windows::UI::Notifications::IToastFailedEventArgs *)
{
if (_signature == TOAST_SIGNATURE)
- Hide();
+ Destroy();
return S_OK;
}
-void ToastNotification::Hide()
+void ToastNotification::Destroy()
{
- if (notification)
- notifier->Hide(notification.Get());
-} \ No newline at end of file
+ if (_signature != TOAST_SIGNATURE) return;
+ {
+ mir_cslock lck(csNotifications);
+ lstNotifications.remove(this);
+ }
+ delete this;
+}
diff --git a/plugins/Toaster/src/toast_notification.h b/plugins/Toaster/src/toast_notification.h
index c8ef097a60..5d5da2c6d7 100644
--- a/plugins/Toaster/src/toast_notification.h
+++ b/plugins/Toaster/src/toast_notification.h
@@ -37,7 +37,7 @@ public:
HRESULT OnDismiss(_In_ ABI::Windows::UI::Notifications::IToastNotification*, _In_ ABI::Windows::UI::Notifications::IToastDismissedEventArgs*);
HRESULT OnFail(_In_ ABI::Windows::UI::Notifications::IToastNotification*, _In_ ABI::Windows::UI::Notifications::IToastFailedEventArgs*);
- void Hide();
+ void Destroy();
__forceinline bool IsValid() const
{ return _signature == TOAST_SIGNATURE;