mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: dangling pointer warning when updating menus (#38690)
fix: dangling raw_ptr warning when updating menus Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user