fix: dangling pointer warning when updating menus (#38643)
This commit is contained in:
parent
95d6a932ca
commit
9d8da7839e
1 changed files with 2 additions and 2 deletions
|
@ -706,8 +706,6 @@ void BaseWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
|||
v8::Local<v8::Object> object;
|
||||
if (value->IsObject() && value->ToObject(context).ToLocal(&object) &&
|
||||
gin::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
|
||||
menu_.Reset(isolate, menu.ToV8());
|
||||
|
||||
// We only want to update the menu if the menu has a non-zero item count,
|
||||
// or we risk crashes.
|
||||
if (menu->model()->GetItemCount() == 0) {
|
||||
|
@ -715,6 +713,8 @@ void BaseWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
|||
} else {
|
||||
window_->SetMenu(menu->model());
|
||||
}
|
||||
|
||||
menu_.Reset(isolate, menu.ToV8());
|
||||
} else if (value->IsNull()) {
|
||||
RemoveMenu();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue