Ensure icon in context menu is not leaked (#709)

This commit is contained in:
Chris Davis 2019-11-13 14:13:14 -08:00 committed by GitHub
parent 3c0b479669
commit b490a72c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -24,6 +24,7 @@ CPowerRenameMenu::CPowerRenameMenu()
CPowerRenameMenu::~CPowerRenameMenu()
{
m_spdo = nullptr;
DeleteObject(m_hbmpIcon);
DllRelease();
}
@ -83,7 +84,11 @@ HRESULT CPowerRenameMenu::QueryContextMenu(HMENU hMenu, UINT index, UINT uIDFirs
if (hIcon)
{
mii.fMask |= MIIM_BITMAP;
mii.hbmpItem = CreateBitmapFromIcon(hIcon);
if (m_hbmpIcon == NULL)
{
m_hbmpIcon = CreateBitmapFromIcon(hIcon);
}
mii.hbmpItem = m_hbmpIcon;
DestroyIcon(hIcon);
}
}

View File

@ -56,6 +56,7 @@ private:
~CPowerRenameMenu();
long m_refCount = 1;
HBITMAP m_hbmpIcon = NULL;
CComPtr<IDataObject> m_spdo;
};