diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-12-29 19:59:31 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-12-29 19:59:31 +0000 |
commit | 544fb33475eb7ea1735f9e19f78dcf3c5e1ceb66 (patch) | |
tree | 9bcf88888f81aeb7e17ad20d9e7fd6fefa684725 | |
parent | 99034f294331209fbfa1d5efacf7fb25f88e227d (diff) |
Toaster: memleaks fix, code clenup
git-svn-id: http://svn.miranda-ng.org/main/trunk@15967 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Toaster/src/add_to_start_menu.h | 7 | ||||
-rw-r--r-- | plugins/Toaster/src/services.cpp | 1 | ||||
-rw-r--r-- | plugins/Toaster/src/stdafx.h | 19 | ||||
-rw-r--r-- | plugins/Toaster/src/string_reference_wrapper.h | 30 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_notification.cpp | 3 | ||||
-rw-r--r-- | plugins/Toaster/src/toast_notification.h | 8 | ||||
-rw-r--r-- | plugins/Toaster/src/utils.cpp (renamed from plugins/Toaster/src/add_to_start_menu.cpp) | 25 | ||||
-rw-r--r-- | plugins/Toaster/src/utils.h (renamed from plugins/Toaster/src/images.h) | 5 |
8 files changed, 37 insertions, 61 deletions
diff --git a/plugins/Toaster/src/add_to_start_menu.h b/plugins/Toaster/src/add_to_start_menu.h deleted file mode 100644 index 45d866c0fd..0000000000 --- a/plugins/Toaster/src/add_to_start_menu.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ADD_TOSTART_MENU_H_
-#define _ADD_TOSTART_MENU_H_
-
-DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5);
-HRESULT TryCreateShortcut();
-
-#endif //_ADD_TOSTART_MENU_H_
\ No newline at end of file diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 9342af8672..f217367509 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -165,7 +165,6 @@ static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam) static INT_PTR UnRegisterClass(WPARAM, LPARAM lParam)
{
-
for (auto it = mp_Classes.begin(); it != mp_Classes.end(); it++)
{
if (it->second == (void*)lParam)
diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h index 3faa59fec7..5b4df4701c 100644 --- a/plugins/Toaster/src/stdafx.h +++ b/plugins/Toaster/src/stdafx.h @@ -19,7 +19,6 @@ #include <m_chat.h>
#include <m_skin.h>
#include <m_imgsrvc.h>
-#include <m_netlib.h>
#include <m_xml.h>
#include <m_options.h>
#include <m_gui.h>
@@ -27,22 +26,22 @@ #include "version.h"
#include "resource.h"
-const wchar_t AppUserModelID[] = _T("MirandaNG");
+const wchar_t AppUserModelID[] = L"MirandaNG";
#define MODULE "Toaster"
#define CHECKHR(x) if (FAILED(x)) return x;
-#include "string_reference_wrapper.h"
-#include "toast_notification.h"
-#include "add_to_start_menu.h"
-#include "options.h"
-#include "structs.h"
-#include "images.h"
-
+class ToastNotification;
extern HINSTANCE g_hInstance;
extern mir_cs csNotifications;
-extern OBJLIST<ToastNotification> lstNotifications;
extern wchar_t wszTempDir[MAX_PATH];
+extern OBJLIST<ToastNotification> lstNotifications;
+
+#include "string_reference_wrapper.h"
+#include "utils.h"
+#include "options.h"
+#include "structs.h"
+#include "toast_notification.h"
void CleanupClasses();
void InitServices();
diff --git a/plugins/Toaster/src/string_reference_wrapper.h b/plugins/Toaster/src/string_reference_wrapper.h index 6daeb0fee1..addfb32394 100644 --- a/plugins/Toaster/src/string_reference_wrapper.h +++ b/plugins/Toaster/src/string_reference_wrapper.h @@ -1,47 +1,31 @@ -#ifndef _STRING_WRAPPER_H_
-#define _STRING_WRAPPER_H_
+#pragma once
class StringReferenceWrapper
{
public:
StringReferenceWrapper(_In_reads_(length) PCWSTR stringRef, _In_ UINT32 length) throw()
- {
- HRESULT hr = WindowsCreateStringReference(stringRef, length, &_header, &_hstring);
-
- if (FAILED(hr))
- RaiseException(static_cast<DWORD>(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr);
+ { WindowsCreateStringReference(stringRef, length, &_header, &_hstring);
}
template <size_t N>
StringReferenceWrapper(_In_reads_(N) wchar_t const (&stringRef)[N]) throw()
- {
- UINT32 length = N - 1;
- HRESULT hr = WindowsCreateStringReference(stringRef, length, &_header, &_hstring);
-
- if (FAILED(hr))
- RaiseException(static_cast<DWORD>(STATUS_INVALID_PARAMETER), EXCEPTION_NONCONTINUABLE, 0, nullptr);
+ { WindowsCreateStringReference(stringRef, (UINT32)(N - 1), &_header, &_hstring);
}
template <size_t _>
StringReferenceWrapper(_In_reads_(_) wchar_t(&stringRef)[_]) throw()
- {
- size_t length = mir_wstrlen(stringRef);
- WindowsCreateStringReference(stringRef, length, &_header, &_hstring);
+ { WindowsCreateStringReference(stringRef, mir_wstrlen(stringRef), &_header, &_hstring);
}
~StringReferenceWrapper()
- {
- WindowsDeleteString(_hstring);
+ { WindowsDeleteString(_hstring);
}
HSTRING Get() const throw()
- {
- return _hstring;
+ { return _hstring;
}
private:
HSTRING _hstring;
HSTRING_HEADER _header;
-};
-
-#endif //_STRING_WRAPPER_H_
\ No newline at end of file +};
\ No newline at end of file diff --git a/plugins/Toaster/src/toast_notification.cpp b/plugins/Toaster/src/toast_notification.cpp index 1d1c73aed4..70a2872396 100644 --- a/plugins/Toaster/src/toast_notification.cpp +++ b/plugins/Toaster/src/toast_notification.cpp @@ -23,7 +23,6 @@ ToastNotification::ToastNotification( notification->add_Dismissed(Callback<ToastDismissHandler>(this, &ToastNotification::OnDismiss).Get(), &_ertDismissed);
notification->add_Failed(Callback<ToastFailHandler>(this, &ToastNotification::OnFail).Get(), &_ertFailed);
notifier->Show(notification.Get());
-
}
ToastNotification::~ToastNotification()
@@ -62,7 +61,7 @@ HRESULT ToastNotification::CreateXml(_Outptr_ ABI::Windows::Data::Xml::Dom::IXml }
int nLength;
- TCHAR *xtmp = xmlToString(xmlToast, &nLength);
+ ptrT xtmp(xmlToString(xmlToast, &nLength));
xmlDestroyNode(xmlToast);
CHECKHR(xmlDocument->LoadXml(StringReferenceWrapper(xtmp, nLength).Get()));
diff --git a/plugins/Toaster/src/toast_notification.h b/plugins/Toaster/src/toast_notification.h index 757cf269d5..2320cbce99 100644 --- a/plugins/Toaster/src/toast_notification.h +++ b/plugins/Toaster/src/toast_notification.h @@ -1,17 +1,9 @@ #pragma once
-typedef ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification *, ::IInspectable *> DesktopToastActivatedEventHandler;
-typedef ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification *, ABI::Windows::UI::Notifications::ToastDismissedEventArgs *> DesktopToastDismissedEventHandler;
-typedef ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification *, ABI::Windows::UI::Notifications::ToastFailedEventArgs *> DesktopToastFailedEventHandler;
typedef __FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_IInspectable ToastActivationHandler;
typedef __FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_Windows__CUI__CNotifications__CToastDismissedEventArgs ToastDismissHandler;
typedef __FITypedEventHandler_2_Windows__CUI__CNotifications__CToastNotification_Windows__CUI__CNotifications__CToastFailedEventArgs ToastFailHandler;
-class ToastNotification;
-
-extern OBJLIST<ToastNotification> lstNotifications;
-extern mir_cs csNotifications;
-
class ToastNotification
{
private:
diff --git a/plugins/Toaster/src/add_to_start_menu.cpp b/plugins/Toaster/src/utils.cpp index 612ac322d7..86062d2f4a 100644 --- a/plugins/Toaster/src/add_to_start_menu.cpp +++ b/plugins/Toaster/src/utils.cpp @@ -31,17 +31,22 @@ HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath) HRESULT hr = InitPropVariantFromString(AppUserModelID, &appIdPropVar);
if (SUCCEEDED(hr))
{
- CHECKHR(propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar));
-
- CHECKHR(propertyStore->Commit());
-
- ComPtr<IPersistFile> persistFile;
- CHECKHR(hr = shellLink.As(&persistFile))
-
- hr = persistFile->Save(shortcutPath, TRUE);
+ hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
+ if (SUCCEEDED(hr))
+ {
+ hr = propertyStore->Commit();
+ if (SUCCEEDED(hr))
+ {
+ ComPtr<IPersistFile> persistFile;
+ hr = shellLink.As(&persistFile);
+ if (SUCCEEDED(hr))
+ {
+ hr = persistFile->Save(shortcutPath, TRUE);
+ }
+ }
+ }
+ PropVariantClear(&appIdPropVar);
}
- PropVariantClear(&appIdPropVar);
-
return hr;
}
diff --git a/plugins/Toaster/src/images.h b/plugins/Toaster/src/utils.h index 01b05720d1..858d04f1be 100644 --- a/plugins/Toaster/src/images.h +++ b/plugins/Toaster/src/utils.h @@ -1,3 +1,8 @@ +#pragma once
+
+DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5);
+HRESULT TryCreateShortcut();
+
extern wchar_t wszTempDir[];
class ToasterImage
|