fix: menu should not be garbage-collected when popuping (#21169)
* fix: retain menu when popuping * test: menu should not be garbage-collected when popuping
This commit is contained in:
parent
ea23f18e94
commit
50f2d2b5ab
9 changed files with 82 additions and 33 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "shell/browser/api/atom_api_menu.h"
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "shell/common/gin_converters/accelerator_converter.h"
|
||||
|
@ -217,6 +218,16 @@ void Menu::OnMenuWillShow() {
|
|||
Emit("menu-will-show");
|
||||
}
|
||||
|
||||
base::OnceClosure Menu::BindSelfToClosure(base::OnceClosure callback) {
|
||||
// return ((callback, ref) => { callback() }).bind(null, callback, this)
|
||||
v8::Global<v8::Value> ref(isolate(), GetWrapper());
|
||||
return base::BindOnce(
|
||||
[](base::OnceClosure callback, v8::Global<v8::Value> ref) {
|
||||
std::move(callback).Run();
|
||||
},
|
||||
std::move(callback), std::move(ref));
|
||||
}
|
||||
|
||||
// static
|
||||
void Menu::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue