fix: prevent PopUpButtonHandler premature dealloc (#40308)

fix: prevent PopUpButtonHandler dealloc
This commit is contained in:
Shelley Vohr 2023-10-26 11:40:02 -04:00 committed by GitHub
parent 621b3ba897
commit 3f92a98315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,14 +66,18 @@
// 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
@ -149,6 +153,7 @@ void SetAllowedFileTypes(NSSavePanel* dialog, const Filters& filters) {
[accessoryView addSubview:label];
[accessoryView addSubview:popupButton];
[accessoryView setPopUpButtonHandler:popUpButtonHandler];
[dialog setAccessoryView:accessoryView];
}