diff options
author | George Hazan <ghazan@miranda.im> | 2022-06-29 15:56:38 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-06-29 15:56:38 +0300 |
commit | c053264e73a9ce72ca1ebf89c795f0939f4d74ea (patch) | |
tree | 797b7ea55c091c938d3f9acf27a5a62cebb1bb6a | |
parent | 3bace5a63029cc6210256523a0f0a658e34bc4b7 (diff) |
Toaster: useless method Destroy() inlined, Hide() introduced instead of it to remove a popup
-rw-r--r-- | plugins/Toaster/src/services.cpp | 3 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_notification.cpp | 23 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_notification.h | 4 |
3 files changed, 15 insertions, 15 deletions
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 7f2ce75ab7..389607d748 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -181,7 +181,8 @@ static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) static INT_PTR HideToast(WPARAM, LPARAM lParam)
{
auto *pNotification = (ToastNotification*)lParam;
- pNotification->Destroy();
+ if (pNotification)
+ pNotification->Hide();
return 0;
}
diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp index 11700b7287..d0778ff384 100644 --- a/plugins/Toaster/src/toast_notification.cpp +++ b/plugins/Toaster/src/toast_notification.cpp @@ -46,9 +46,6 @@ 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)
@@ -103,7 +100,11 @@ HRESULT ToastNotification::Create(_Outptr_ ABI::Windows::UI::Notifications::IToa HRESULT ToastNotification::OnActivate(_In_ ABI::Windows::UI::Notifications::IToastNotification *, IInspectable *)
{
CallPopupProc(WM_COMMAND);
- Destroy();
+ {
+ mir_cslock lck(csNotifications);
+ lstNotifications.remove(this);
+ }
+ delete this;
return S_OK;
}
@@ -114,7 +115,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);
- Destroy();
+ Hide();
}
return S_OK;
}
@@ -122,14 +123,12 @@ 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)
- Destroy();
+ Hide();
return S_OK;
}
-void ToastNotification::Destroy()
+void ToastNotification::Hide()
{
- { mir_cslock lck(csNotifications);
- lstNotifications.remove(this);
- }
- delete this;
-}
+ if (notification)
+ notifier->Hide(notification.Get());
+}
\ No newline at end of file diff --git a/plugins/Toaster/src/toast_notification.h b/plugins/Toaster/src/toast_notification.h index 2b730c1d23..c8ef097a60 100644 --- a/plugins/Toaster/src/toast_notification.h +++ b/plugins/Toaster/src/toast_notification.h @@ -37,6 +37,8 @@ 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();
+
__forceinline bool IsValid() const
{ return _signature == TOAST_SIGNATURE;
}
@@ -52,6 +54,4 @@ public: __forceinline LRESULT CallPopupProc(UINT uMsg)
{ return (_pfnPopupProc ? _pfnPopupProc((HWND)this, uMsg, 0, 0) : 0);
}
-
- void Destroy();
};
|