Skip to content

Commit

Permalink
[macOS] Fixes Crash of cxx destruction when App will terminate (flutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw authored Nov 3, 2021
1 parent b375bf8 commit a926664
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ static void CommonInit(FlutterViewController* controller) {
selector:@selector(onAccessibilityStatusChanged:)
name:EnhancedUserInterfaceNotification
object:nil];
[center addObserver:controller
selector:@selector(applicationWillTerminate:)
name:NSApplicationWillTerminateNotification
object:nil];
}

- (instancetype)initWithCoder:(NSCoder*)coder {
Expand Down Expand Up @@ -557,6 +561,13 @@ - (void)dispatchMouseEvent:(NSEvent*)event phase:(FlutterPointerPhase)phase {
}
}

- (void)applicationWillTerminate:(NSNotification*)notification {
if (!_engine) {
return;
}
[_engine shutDownEngine];
}

- (void)onAccessibilityStatusChanged:(NSNotification*)notification {
if (!_engine) {
return;
Expand Down

0 comments on commit a926664

Please sign in to comment.