diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-05 16:57:06 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-05 16:57:06 +0000 |
commit | 20909e75299487e598ee307450df4abfb003b4ff (patch) | |
tree | 7d557ebebb69ab7998a0ba033f4ab3ce064f34d7 /ui/base | |
parent | c0cecd1fb74b856db81c03eac8b39078add7e53f (diff) | |
download | chromium_src-20909e75299487e598ee307450df4abfb003b4ff.zip chromium_src-20909e75299487e598ee307450df4abfb003b4ff.tar.gz chromium_src-20909e75299487e598ee307450df4abfb003b4ff.tar.bz2 |
Adds some debugging code to help isolate a crash.
BUG=121084
TEST=none
R=cpu@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9958125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/win/window_impl.cc | 35 | ||||
-rw-r--r-- | ui/base/win/window_impl.h | 6 |
2 files changed, 35 insertions, 6 deletions
diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc index 296ca85..216a77c 100644 --- a/ui/base/win/window_impl.cc +++ b/ui/base/win/window_impl.cc @@ -6,6 +6,7 @@ #include <list> +#include "base/debug/alias.h" #include "base/memory/singleton.h" #include "base/string_number_conversions.h" #include "base/win/wrapped_window_proc.h" @@ -143,10 +144,15 @@ WindowImpl::WindowImpl() : window_style_(0), window_ex_style_(kWindowDefaultExStyle), class_style_(CS_DBLCLKS), - hwnd_(NULL) { + hwnd_(NULL), + got_create_(false), + got_valid_hwnd_(false), + destroyed_(NULL) { } WindowImpl::~WindowImpl() { + if (destroyed_) + *destroyed_ = true; if (::IsWindow(hwnd_)) ui::SetWindowUserData(hwnd_, NULL); } @@ -177,13 +183,27 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) { } std::wstring name(GetWindowClassName()); - hwnd_ = CreateWindowEx(window_ex_style_, name.c_str(), NULL, - window_style_, x, y, width, height, - parent, NULL, NULL, this); - CheckWindowCreated(hwnd_); + bool destroyed = false; + destroyed_ = &destroyed; + HWND hwnd = CreateWindowEx(window_ex_style_, name.c_str(), NULL, + window_style_, x, y, width, height, + parent, NULL, NULL, this); + if (!hwnd_) { + base::debug::Alias(&destroyed); + base::debug::Alias(&hwnd); + DWORD last_error = GetLastError(); + base::debug::Alias(&last_error); + bool got_create = got_create_; + base::debug::Alias(&got_create); + bool got_valid_hwnd = got_valid_hwnd_; + base::debug::Alias(&got_valid_hwnd); + CHECK(false); + } + if (!destroyed) + destroyed_ = NULL; // The window procedure should have set the data for us. - CHECK_EQ(this, ui::GetWindowUserData(hwnd_)); + CHECK_EQ(this, ui::GetWindowUserData(hwnd)); } HICON WindowImpl::GetDefaultWindowIcon() const { @@ -212,6 +232,9 @@ LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, DCHECK(window); ui::SetWindowUserData(hwnd, window); window->hwnd_ = hwnd; + window->got_create_ = true; + if (hwnd) + window->got_valid_hwnd_ = true; return TRUE; } diff --git a/ui/base/win/window_impl.h b/ui/base/win/window_impl.h index dce6581..1f70920 100644 --- a/ui/base/win/window_impl.h +++ b/ui/base/win/window_impl.h @@ -104,6 +104,12 @@ class UI_EXPORT WindowImpl : public MessageMapInterface { // Our hwnd. HWND hwnd_; + // For debugging. + // TODO(sky): nuke this when get crash data. + bool got_create_; + bool got_valid_hwnd_; + bool* destroyed_; + DISALLOW_COPY_AND_ASSIGN(WindowImpl); }; |