From 96e20826f358a32e38c3f052243375982543c05b Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 2 Oct 2015 14:54:34 +0200 Subject: 6.14 --- zen/notify_removal.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'zen/notify_removal.cpp') diff --git a/zen/notify_removal.cpp b/zen/notify_removal.cpp index 37f305c9..f528e81b 100644 --- a/zen/notify_removal.cpp +++ b/zen/notify_removal.cpp @@ -86,7 +86,7 @@ MessageProvider::MessageProvider() : if (::RegisterClass(&wc) == 0) throwFileError(_("Unable to register to receive system messages."), L"RegisterClass", getLastError()); - ScopeGuard guardClass = makeGuard([&] { ::UnregisterClass(dummyClassName, hMainModule); }); + ScopeGuard guardConstructor = zen::makeGuard([&] { this->~MessageProvider(); }); //create dummy-window windowHandle = ::CreateWindow(dummyClassName, //_In_opt_ LPCTSTR lpClassName, @@ -106,14 +106,15 @@ MessageProvider::MessageProvider() : if (::SetWindowLongPtr(windowHandle, GWLP_USERDATA, reinterpret_cast(this)) == 0 && ::GetLastError() != ERROR_SUCCESS) throwFileError(_("Unable to register to receive system messages."), L"SetWindowLongPtr", ::GetLastError()); - guardClass.dismiss(); + guardConstructor.dismiss(); } MessageProvider::~MessageProvider() { //clean-up in reverse order - ::DestroyWindow(windowHandle); + if (windowHandle) + ::DestroyWindow(windowHandle); ::UnregisterClass(dummyClassName, //LPCTSTR lpClassName OR ATOM in low-order word! hMainModule); //HINSTANCE hInstance } -- cgit