From: Kevin Sawicki Date: Wed, 22 Feb 2017 19:47:58 +0000 (-0800) Subject: Invoke close callback after itemSelected runs X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=211bedf9104edf5cd19a0d879bba78de590ed6d2;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Invoke close callback after itemSelected runs --- diff --git a/atom/browser/ui/cocoa/atom_menu_controller.mm b/atom/browser/ui/cocoa/atom_menu_controller.mm index 2286b6b..b3e2931 100644 --- a/atom/browser/ui/cocoa/atom_menu_controller.mm +++ b/atom/browser/ui/cocoa/atom_menu_controller.mm @@ -12,9 +12,12 @@ #include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/platform_accelerator_cocoa.h" #include "ui/base/l10n/l10n_util_mac.h" +#include "content/public/browser/browser_thread.h" #include "ui/events/cocoa/cocoa_event_utils.h" #include "ui/gfx/image/image.h" +using content::BrowserThread; + namespace { struct Role { @@ -271,8 +274,11 @@ Role kRolesMap[] = { if (isMenuOpen_) { isMenuOpen_ = NO; model_->MenuWillClose(); + + // Post async task so that itemSelected runs before the close callback + // deletes the controller from the map which deallocates it if (!closeCallback.is_null()) - closeCallback.Run(); + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, closeCallback); } }