fix: tray garbage collection (#33040)

This commit is contained in:
Shelley Vohr 2022-02-24 20:03:59 +01:00 committed by GitHub
parent 8cf345660c
commit c5a2af7811
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -89,8 +89,10 @@ gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
}
#endif
return gin::CreateHandle(thrower.isolate(),
new Tray(args->isolate(), image, guid));
auto handle = gin::CreateHandle(args->isolate(),
new Tray(args->isolate(), image, guid));
handle->Pin(args->isolate());
return handle;
}
void Tray::OnClicked(const gfx::Rect& bounds,
@ -180,6 +182,7 @@ void Tray::OnDragEnded() {
}
void Tray::Destroy() {
Unpin();
menu_.Reset();
tray_icon_.reset();
}