Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect tray garbage collection #33074

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions shell/browser/api/electron_api_tray.cc
Expand Up @@ -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,
Expand Down Expand Up @@ -180,6 +182,7 @@ void Tray::OnDragEnded() {
}

void Tray::Destroy() {
Unpin();
menu_.Reset();
tray_icon_.reset();
}
Expand Down
2 changes: 2 additions & 0 deletions shell/browser/api/electron_api_tray.h
Expand Up @@ -19,6 +19,7 @@
#include "shell/common/gin_helper/cleaned_up_at_exit.h"
#include "shell/common/gin_helper/constructible.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/pinnable.h"

namespace gfx {
class Image;
Expand All @@ -38,6 +39,7 @@ class Tray : public gin::Wrappable<Tray>,
public gin_helper::EventEmitterMixin<Tray>,
public gin_helper::Constructible<Tray>,
public gin_helper::CleanedUpAtExit,
public gin_helper::Pinnable<Tray>,
public TrayIconObserver {
public:
// gin_helper::Constructible
Expand Down