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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 279073002: views: Terminate the nested message-loop correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 // MessagePumpDispatcher is only invoked before native events, which means 2371 // MessagePumpDispatcher is only invoked before native events, which means
2372 // its entirely possible for a Widget::CloseNow() task to be processed before 2372 // its entirely possible for a Widget::CloseNow() task to be processed before
2373 // the next native message. We quite the nested message loop as soon as 2373 // the next native message. We quite the nested message loop as soon as
2374 // possible to avoid having deleted views classes (such as widgets and 2374 // possible to avoid having deleted views classes (such as widgets and
2375 // rootviews) on the stack when the nested message loop stops. 2375 // rootviews) on the stack when the nested message loop stops.
2376 // 2376 //
2377 // It's safe to invoke QuitNestedMessageLoop() multiple times, it only effects 2377 // It's safe to invoke QuitNestedMessageLoop() multiple times, it only effects
2378 // the current loop. 2378 // the current loop.
2379 bool quit_now = ShouldQuitNow() && exit_type_ != EXIT_NONE && 2379 bool quit_now = ShouldQuitNow() && exit_type_ != EXIT_NONE &&
2380 message_loop_depth_; 2380 message_loop_depth_;
2381 if (quit_now)
2382 TerminateNestedMessageLoop();
2383 }
2381 2384
2382 if (quit_now) { 2385 void MenuController::TerminateNestedMessageLoop() {
2383 if (owner_) { 2386 if (owner_) {
2384 aura::Window* root = owner_->GetNativeWindow()->GetRootWindow(); 2387 aura::Window* root = owner_->GetNativeWindow()->GetRootWindow();
2385 aura::client::GetDispatcherClient(root)->QuitNestedMessageLoop(); 2388 aura::client::GetDispatcherClient(root)->QuitNestedMessageLoop();
2386 } else { 2389 } else {
2387 base::MessageLoop::current()->QuitNow(); 2390 base::MessageLoop::current()->QuitNow();
2388 }
2389 // Restore the previous dispatcher.
2390 nested_dispatcher_.reset();
2391 } 2391 }
2392 // Restore the previous dispatcher.
2393 nested_dispatcher_.reset();
2392 } 2394 }
2393 2395
2394 bool MenuController::ShouldQuitNow() const { 2396 bool MenuController::ShouldQuitNow() const {
2395 aura::Window* root = GetOwnerRootWindow(owner_); 2397 aura::Window* root = GetOwnerRootWindow(owner_);
2396 return !aura::client::GetDragDropClient(root) || 2398 return !aura::client::GetDragDropClient(root) ||
2397 !aura::client::GetDragDropClient(root)->IsDragDropInProgress(); 2399 !aura::client::GetDragDropClient(root)->IsDragDropInProgress();
2398 } 2400 }
2399 2401
2400 void MenuController::HandleMouseLocation(SubmenuView* source, 2402 void MenuController::HandleMouseLocation(SubmenuView* source,
2401 const gfx::Point& mouse_location) { 2403 const gfx::Point& mouse_location) {
(...skipping 27 matching lines...) Expand all
2429 } 2431 }
2430 } 2432 }
2431 2433
2432 gfx::Screen* MenuController::GetScreen() { 2434 gfx::Screen* MenuController::GetScreen() {
2433 aura::Window* root = GetOwnerRootWindow(owner_); 2435 aura::Window* root = GetOwnerRootWindow(owner_);
2434 return root ? gfx::Screen::GetScreenFor(root) 2436 return root ? gfx::Screen::GetScreenFor(root)
2435 : gfx::Screen::GetNativeScreen(); 2437 : gfx::Screen::GetNativeScreen();
2436 } 2438 }
2437 2439
2438 } // namespace views 2440 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698