diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 16:57:13 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-01 16:57:13 +0000 |
commit | 7c9d829192359328576965fe8a4a52a5ad6c7da3 (patch) | |
tree | 6f06ef0a1bd4f797ad2c9f2968950b625867136c /views/controls/menu/native_menu_win.cc | |
parent | 9d3fcf8bc99dfdfef66b983af69802ddbe76514d (diff) | |
download | chromium_src-7c9d829192359328576965fe8a4a52a5ad6c7da3.zip chromium_src-7c9d829192359328576965fe8a4a52a5ad6c7da3.tar.gz chromium_src-7c9d829192359328576965fe8a4a52a5ad6c7da3.tar.bz2 |
Attempt at fixing leaks from SetProp. Apparently there is a finite
amount of memory reserved for properties and Windows doesn't always
automatically free up the memory if the window is deleted without an
explicit remove. For the time being I've made it easier to track
SetProp leaks, but we may want to move to using something other than
SetProp in the future that isn't as fragile.
I didn't fix a couple of places that were trickier. I'm going to file
separate bugs on them.
BUG=44991
TEST=none
Review URL: http://codereview.chromium.org/4195003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu/native_menu_win.cc')
-rw-r--r-- | views/controls/menu/native_menu_win.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc index 6236913..9993d4e 100644 --- a/views/controls/menu/native_menu_win.cc +++ b/views/controls/menu/native_menu_win.cc @@ -9,6 +9,7 @@ #include "app/l10n_util_win.h" #include "base/logging.h" #include "base/stl_util-inl.h" +#include "base/win_util.h" #include "gfx/canvas_skia.h" #include "gfx/font.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -55,18 +56,16 @@ class NativeMenuWin::MenuHostWindow { RegisterClass(); hwnd_ = CreateWindowEx(l10n_util::GetExtendedStyles(), kWindowClassName, L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); - SetProp(hwnd_, kMenuHostWindowKey, this); + win_util::SetWindowUserData(hwnd_, this); } ~MenuHostWindow() { - RemoveProp(hwnd_, kMenuHostWindowKey); DestroyWindow(hwnd_); } HWND hwnd() const { return hwnd_; } private: - static const wchar_t* kMenuHostWindowKey; static const wchar_t* kWindowClassName; void RegisterClass() { @@ -276,7 +275,8 @@ class NativeMenuWin::MenuHostWindow { WPARAM w_param, LPARAM l_param) { MenuHostWindow* host = - reinterpret_cast<MenuHostWindow*>(GetProp(window, kMenuHostWindowKey)); + reinterpret_cast<MenuHostWindow*>(win_util::GetWindowUserData(window)); + // host is null during initial construction. LRESULT l_result = 0; if (!host || !host->ProcessWindowMessage(window, message, w_param, l_param, &l_result)) { @@ -294,10 +294,6 @@ class NativeMenuWin::MenuHostWindow { const wchar_t* NativeMenuWin::MenuHostWindow::kWindowClassName = L"ViewsMenuHostWindow"; -const wchar_t* NativeMenuWin::MenuHostWindow::kMenuHostWindowKey = - L"__MENU_HOST_WINDOW__"; - - //////////////////////////////////////////////////////////////////////////////// // NativeMenuWin, public: |