From 63bb78db26ed509e9b12b586bafeb81f8bce40a5 Mon Sep 17 00:00:00 2001 From: "sky@google.com" Date: Wed, 25 Mar 2009 19:42:39 +0000 Subject: Fixes crash that occurred because we weren't correctly disposing of the native HWND for buttons. BUG=9301 TEST=see bug Review URL: http://codereview.chromium.org/42609 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12481 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/views/controls/native_control_win.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'chrome') diff --git a/chrome/views/controls/native_control_win.cc b/chrome/views/controls/native_control_win.cc index e8574f0..827f509 100644 --- a/chrome/views/controls/native_control_win.cc +++ b/chrome/views/controls/native_control_win.cc @@ -27,6 +27,14 @@ NativeControlWin::NativeControlWin() : HWNDView() { } NativeControlWin::~NativeControlWin() { + HWND hwnd = GetHWND(); + if (hwnd) { + // Destroy the hwnd if it still exists. Otherwise we won't have shut things + // down correctly, leading to leaking and crashing if another message + // comes in for the hwnd. + Detach(); + DestroyWindow(hwnd); + } } LRESULT NativeControlWin::ProcessMessage(UINT message, WPARAM w_param, -- cgit v1.1