fix: prevent menu gc during popup (#20808)

This commit is contained in:
trop[bot]
2019-10-29 16:25:08 +09:00
committed by Cheng Zhao
parent 32ac551ca5
commit 6e32da3798
3 changed files with 7 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
#include "shell/browser/api/atom_api_top_level_window.h"
#include "shell/browser/api/trackable_object.h"
#include "shell/browser/ui/atom_menu_model.h"
#include "shell/common/api/locker.h"
namespace electron {

View File

@@ -57,6 +57,9 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
int y,
int positioning_item,
base::Closure callback) {
mate::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
if (!native_window)
return;
NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow();

View File

@@ -26,6 +26,9 @@ void MenuViews::PopupAt(TopLevelWindow* window,
int y,
int positioning_item,
const base::Closure& callback) {
mate::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto* native_window = static_cast<NativeWindowViews*>(window->window());
if (!native_window)
return;