Skip to content

Commit

Permalink
Bug 1777553 - Use a weak pres context reference in nsMenuItemIconX. r…
Browse files Browse the repository at this point in the history
…=mac-reviewers,spohl

This is the only thing from the regressing patch that could potentially
cause this macOS leak, realistically. I don't think the leak is
super-worrisome, likely we just shut down the browser before the image
load finishes.

Differential Revision: https://phabricator.services.mozilla.com/D151368
  • Loading branch information
emilio committed Jul 8, 2022
1 parent 492190f commit ebd6957
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion widget/cocoa/nsMenuItemIconX.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import <Cocoa/Cocoa.h>

#include "mozilla/widget/IconLoader.h"
#include "mozilla/WeakPtr.h"

class nsIconLoaderService;
class nsIURI;
Expand Down Expand Up @@ -62,7 +63,7 @@ class nsMenuItemIconX final : public mozilla::widget::IconLoader::Listener {
Listener* mListener; // [weak]
nsIntRect mImageRegionRect;
RefPtr<const mozilla::ComputedStyle> mComputedStyle;
RefPtr<nsPresContext> mPresContext;
mozilla::WeakPtr<nsPresContext> mPresContext;
NSImage* mIconImage = nil; // [strong]
RefPtr<mozilla::widget::IconLoader> mIconLoader;
};
Expand Down
4 changes: 2 additions & 2 deletions widget/cocoa/nsMenuItemIconX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@
[mIconImage release];
mIconImage = nil;
}

RefPtr<nsPresContext> pc = mPresContext.get();
mIconImage = [[MOZIconHelper iconImageFromImageContainer:aImage
withSize:NSMakeSize(kIconSize, kIconSize)
presContext:mPresContext
presContext:pc
computedStyle:mComputedStyle
subrect:mImageRegionRect
scaleFactor:0.0f] retain];
Expand Down

0 comments on commit ebd6957

Please sign in to comment.