Skip to content

Commit

Permalink
Ensure icon in context menu is not leaked (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrdavis committed Nov 13, 2019
1 parent 3c0b479 commit b490a72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/powerrename/dll/PowerRenameExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CPowerRenameMenu::CPowerRenameMenu()
CPowerRenameMenu::~CPowerRenameMenu()
{
m_spdo = nullptr;
DeleteObject(m_hbmpIcon);
DllRelease();
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/powerrename/dll/PowerRenameExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CPowerRenameMenu :
~CPowerRenameMenu();

long m_refCount = 1;
HBITMAP m_hbmpIcon = NULL;
CComPtr<IDataObject> m_spdo;
};

1 comment on commit b490a72

@paulcam206
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Please sign in to comment.