Skip to content

Commit

Permalink
fix: prevent PopUpButtonHandler premature dealloc (#40346)
Browse files Browse the repository at this point in the history
fix: prevent PopUpButtonHandler dealloc

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Oct 26, 2023
1 parent 8148ba5 commit bb0dd34
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shell/browser/ui/file_dialog_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ - (void)selectFormat:(id)sender {

// Manages the PopUpButtonHandler.
@interface ElectronAccessoryView : NSView
@property(nonatomic, strong) PopUpButtonHandler* popUpButtonHandler;
@end

@implementation ElectronAccessoryView

@synthesize popUpButtonHandler;

- (void)dealloc {
auto* popupButton =
static_cast<NSPopUpButton*>([[self subviews] objectAtIndex:1]);
popupButton.target = nil;
popUpButtonHandler = nil;
}

@end
Expand Down Expand Up @@ -149,6 +153,7 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {

[accessoryView addSubview:label];
[accessoryView addSubview:popupButton];
[accessoryView setPopUpButtonHandler:popUpButtonHandler];

[dialog setAccessoryView:accessoryView];
}
Expand Down

0 comments on commit bb0dd34

Please sign in to comment.