bug 708033. Cache the large and small icons that are set for each nsWindow. Free them in nsWindow::~nsWindow() rather than in nsWindow::OnDestroy(). r=jimm

This commit is contained in:
Tim Abraldes 2012-07-05 16:06:13 -07:00
parent e66f91f91c
commit e5ac4db667
2 changed files with 13 additions and 9 deletions

View File

@ -308,6 +308,8 @@ nsWindow::nsWindow() : nsBaseWidget()
}
#endif
mIconSmall = nsnull;
mIconBig = nsnull;
mWnd = nsnull;
mPaintDC = nsnull;
mPrevWndProc = nsnull;
@ -390,6 +392,13 @@ nsWindow::~nsWindow()
if (NULL != mWnd)
Destroy();
// Free app icon resources. This must happen after `OnDestroy` (see bug 708033).
if (mIconSmall)
::DestroyIcon(mIconSmall);
if (mIconBig)
::DestroyIcon(mIconBig);
sInstanceCount--;
// Global shutdown
@ -2824,6 +2833,7 @@ NS_METHOD nsWindow::SetIcon(const nsAString& aIconSpec)
HICON icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)bigIcon);
if (icon)
::DestroyIcon(icon);
mIconBig = bigIcon;
}
#ifdef DEBUG_SetIcon
else {
@ -2837,6 +2847,7 @@ NS_METHOD nsWindow::SetIcon(const nsAString& aIconSpec)
HICON icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)smallIcon);
if (icon)
::DestroyIcon(icon);
mIconSmall = smallIcon;
}
#ifdef DEBUG_SetIcon
else {
@ -6945,15 +6956,6 @@ void nsWindow::OnDestroy()
mBrush = NULL;
}
// Free app icon resources.
HICON icon;
icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM) 0);
if (icon)
::DestroyIcon(icon);
icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) 0);
if (icon)
::DestroyIcon(icon);
// Destroy any custom cursor resources.
if (mCursor == -1)

View File

@ -481,6 +481,8 @@ protected:
WindowHook mWindowHook;
DWORD mAssumeWheelIsZoomUntil;
PRUint32 mPickerDisplayCount;
HICON mIconSmall;
HICON mIconBig;
static bool sDropShadowEnabled;
static PRUint32 sInstanceCount;
static TriStateBool sCanQuit;