-
Trent Apted authored
Crashes show a task coming from -[NSWindow _endWindowBlockingModalSession:returnCode:] (before 10.13) or NSWindowEndWindowModalSession() (10.13 and later). This attempts to access the |modalDelegate| argument given to -[NSApp beginSheet:...], which is not retained, and can be destroyed in some lifetimes. The task is likely the one posted via an asynchronous Close() on a sheet, attempting to close the sheet using [NSApp endSheet:]. If a parent window of a sheet then triggers a more abrupt close, the sheet gets closed via -[NSWindow close] as well. Normally, the delegate would be retained to also end the sheet (to unblock the sheet machinery on the parent). However, this only happens if the sheetParent is non-nil. It appears that under some racy teardown paths the sheet's sheetParent can be nil at this point. To fix, pass the NSWindow itself as |modalDelegate| to permit WeakPtr-like semantics on the ViewsNSWindowDelegate. This allows some confusing lifetimes in ViewsNSWindowDelegate to be tightened up, as well as cleanly handle the mixed close codepaths that we have to cater for. Bug: 851376 Change-Id: I1954dc76f7cff5dc3f54f879aaad51fec12b623f Reviewed-on: https://chromium-review.googlesource.com/1096593 Commit-Queue: Trent Apted <tapted@chromium.org> Reviewed-by:
Robert Sesek <rsesek@chromium.org> Cr-Commit-Position: refs/heads/master@{#567134}
66da0a7a