From 57b07997d325dcae2e25a6093a308e2c8b18ea9a Mon Sep 17 00:00:00 2001 From: fieldingfabian Date: Thu, 13 Oct 2022 14:39:28 +0200 Subject: [PATCH] Win32: Fix memory leaks in ActiveX and WebBrowserComponent --- .../juce_gui_extra/native/juce_win32_ActiveXComponent.cpp | 5 +++++ .../juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 29593758a7..7f1743329e 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -251,6 +251,11 @@ public: ~Pimpl() override { + // If the wndproc of the ActiveX HWND isn't set back to it's original + // wndproc, then clientSite will leak when control is released + if (controlHWND != nullptr) + SetWindowLongPtr ((HWND) controlHWND, GWLP_WNDPROC, (LONG_PTR) originalWndProc); + if (control != nullptr) { control->Close (OLECLOSE_NOSAVE); diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 04083be639..9d3f7a6e59 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -60,7 +60,10 @@ public: ~Win32WebView() override { if (connectionPoint != nullptr) + { connectionPoint->Unadvise (adviseCookie); + connectionPoint->Release(); + } if (browser != nullptr) browser->Release(); @@ -91,6 +94,8 @@ public: handler->Release(); } } + + connectionPointContainer->Release(); } JUCE_END_IGNORE_WARNINGS_GCC_LIKE