summaryrefslogtreecommitdiffstats
path: root/app/win/window_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'app/win/window_impl.cc')
-rw-r--r--app/win/window_impl.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/win/window_impl.cc b/app/win/window_impl.cc
index b28eab5..8ddd2bc 100644
--- a/app/win/window_impl.cc
+++ b/app/win/window_impl.cc
@@ -180,7 +180,15 @@ LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd,
if (!window)
return 0;
- return window->OnWndProc(message, w_param, l_param);
+ LRESULT return_code = window->OnWndProc(message, w_param, l_param);
+
+ // Clean up state. Do this after the above call so subclasses still have a
+ // valid hwnd(). Can't wait until WM_NCDESTROY because by then |hwnd| is not
+ // guaranteed to be reported to us.
+ if (message == WM_DESTROY)
+ window->OnDestroy();
+
+ return return_code;
}
std::wstring WindowImpl::GetWindowClassName() {
@@ -211,4 +219,8 @@ std::wstring WindowImpl::GetWindowClassName() {
return name;
}
+void WindowImpl::OnDestroy() {
+ hwnd_ = 0;
+}
+
} // namespace app