Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1206)

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 1406403007: Eliminate HICON leaks caused by creating icons from bitmap image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add move semantics to ScopedGDIObject. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/win/scoped_gdi_object.h ('K') | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index 7d4857d309c9f5d6215929aeacaa35a42450ed7b..fa2b1f9857e1764af45b975ea4e9878301b88501 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -808,23 +808,14 @@ void HWNDMessageHandler::FrameTypeChanged() {
void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) {
if (!window_icon.isNull()) {
- HICON windows_icon = IconUtil::CreateHICONFromSkBitmap(
- *window_icon.bitmap());
- // We need to make sure to destroy the previous icon, otherwise we'll leak
- // these GDI objects until we crash!
- HICON old_icon = reinterpret_cast<HICON>(
- SendMessage(hwnd(), WM_SETICON, ICON_SMALL,
- reinterpret_cast<LPARAM>(windows_icon)));
- if (old_icon)
- DestroyIcon(old_icon);
+ window_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*window_icon.bitmap()));
sky 2015/11/03 17:23:16 Seems risky to destroy the old icon (as Set destro
+ SendMessage(hwnd(), WM_SETICON, ICON_SMALL,
+ reinterpret_cast<LPARAM>(window_icon_.Get()));
}
if (!app_icon.isNull()) {
- HICON windows_icon = IconUtil::CreateHICONFromSkBitmap(*app_icon.bitmap());
- HICON old_icon = reinterpret_cast<HICON>(
- SendMessage(hwnd(), WM_SETICON, ICON_BIG,
- reinterpret_cast<LPARAM>(windows_icon)));
- if (old_icon)
- DestroyIcon(old_icon);
+ app_icon_.Set(IconUtil::CreateHICONFromSkBitmap(*app_icon.bitmap()));
+ SendMessage(hwnd(), WM_SETICON, ICON_BIG,
+ reinterpret_cast<LPARAM>(app_icon_.Get()));
}
}
« base/win/scoped_gdi_object.h ('K') | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698