clear FancyZones::m_zoneWindowMap on Destroy, since it stores 'this', causing a leak (#664)

This commit is contained in:
yuyoyuppe 2019-11-07 22:05:12 +03:00 committed by GitHub
parent f3e25ae3e6
commit e8edbd5394
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -7,8 +7,8 @@ struct FancyZones : public winrt::implements<FancyZones, IFancyZones, IFancyZone
public:
FancyZones(HINSTANCE hinstance, IFancyZonesSettings* settings) noexcept
: m_hinstance(hinstance)
, m_settings(settings)
{
m_settings.attach(settings);
m_settings->SetCallback(this);
}
@ -85,7 +85,7 @@ private:
bool m_dragEnabled{}; // True if we should be showing zone hints while dragging
std::map<HMONITOR, winrt::com_ptr<IZoneWindow>> m_zoneWindowMap; // Map of monitor to ZoneWindow (one per monitor)
winrt::com_ptr<IZoneWindow> m_zoneWindowMoveSize; // "Active" ZoneWindow, where the move/size is happening. Will update as drag moves between monitors.
winrt::com_ptr<IFancyZonesSettings> m_settings;
IFancyZonesSettings* m_settings{};
GUID m_currentVirtualDesktopId{};
wil::unique_handle m_terminateEditorEvent;
@ -134,7 +134,7 @@ IFACEMETHODIMP_(void) FancyZones::Run() noexcept
IFACEMETHODIMP_(void) FancyZones::Destroy() noexcept
{
std::unique_lock writeLock(m_lock);
m_zoneWindowMap.clear();
BufferedPaintUnInit();
if (m_window)
{

View file

@ -11,7 +11,7 @@ public:
LoadSettings(name, true /*fromFile*/);
}
IFACEMETHODIMP_(void) SetCallback(IFancyZonesCallback* callback) { m_callback.attach(callback); }
IFACEMETHODIMP_(void) SetCallback(IFancyZonesCallback* callback) { m_callback = callback; }
IFACEMETHODIMP_(bool) GetConfig(_Out_ PWSTR buffer, _Out_ int *buffer_sizeg) noexcept;
IFACEMETHODIMP_(void) SetConfig(PCWSTR config) noexcept;
IFACEMETHODIMP_(void) CallCustomAction(PCWSTR action) noexcept;
@ -21,7 +21,7 @@ private:
void LoadSettings(PCWSTR config, bool fromFile) noexcept;
void SaveSettings() noexcept;
winrt::com_ptr<IFancyZonesCallback> m_callback;
IFancyZonesCallback* m_callback{};
const HINSTANCE m_hinstance;
PCWSTR m_name{};