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

Unified Diff: ui/views/widget/native_widget_win.cc

Issue 10154013: Fixes crash in closing menus. There are two issues here: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixor Created 8 years, 8 months 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
Index: ui/views/widget/native_widget_win.cc
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index ede049e6e11767a0bf57947d692050ca3158dc63..216b1fba752e05cca8a8d885b1da496397fc78cc 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -321,6 +321,21 @@ const int kCustomObjectID = 1;
const int kDragFrameWindowAlpha = 200;
+struct FindOwnedWindowsData {
+ HWND window;
+ std::vector<Widget*> owned_widgets;
+};
+
+BOOL CALLBACK FindOwnedWindowsCallback(HWND hwnd, LPARAM param) {
+ FindOwnedWindowsData* data = reinterpret_cast<FindOwnedWindowsData*>(param);
+ if (GetWindow(hwnd, GW_OWNER) == data->window) {
+ Widget* widget = Widget::GetWidgetForNativeView(hwnd);
+ if (widget)
+ data->owned_widgets.push_back(widget);
+ }
+ return TRUE;
+}
+
} // namespace
// static
@@ -891,6 +906,9 @@ void NativeWidgetWin::Hide() {
SetWindowPos(NULL, 0, 0, 0, 0,
SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+
+ if (!GetParent())
+ NotifyOwnedWindowsParentClosing();
oshima 2012/04/26 03:05:27 Can a widget be closed by Windows?
sky 2012/04/26 03:54:53 Do you mean can windows close out from under us? Y
}
}
@@ -2486,6 +2504,15 @@ void NativeWidgetWin::RestoreEnabledIfNecessary() {
}
}
+void NativeWidgetWin::NotifyOwnedWindowsParentClosing() {
+ FindOwnedWindowsData data;
+ data.window = hwnd();
+ EnumThreadWindows(GetCurrentThreadId(), FindOwnedWindowsCallback,
+ reinterpret_cast<LPARAM>(&data));
+ for (size_t i = 0; i < data.owned_widgets.size(); ++i)
+ data.owned_widgets[i]->OnOwnedParentClosing();
+}
+
void NativeWidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) {
SetMsgHandled(delegate_->OnKeyEvent(key));
}

Powered by Google App Engine
This is Rietveld 408576698