Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1588084 - Add null-checking to isUrlbarFocused to avoid crashes o…
Browse files Browse the repository at this point in the history
…n window shutdown. r=mikedeboer

Differential Revision: https://phabricator.services.mozilla.com/D48966
  • Loading branch information
htwyford committed Oct 11, 2019
1 parent ecf4dd4 commit 4a2116b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions browser/components/touchbar/MacTouchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ class TouchBarHelper {
}

get isUrlbarFocused() {
if (!TouchBarHelper.window || !TouchBarHelper.window.gURLBar) {
return false;
}
return TouchBarHelper.window.gURLBar.focused;
}

Expand Down
5 changes: 5 additions & 0 deletions widget/cocoa/nsTouchBar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ - (void)updatePopover:(NSPopoverTouchBarItem*)aPopoverItem input:(TouchBarInput*

// Special handling to show/hide the search popover if the Urlbar is focused.
if ([[aInput nativeIdentifier] isEqualToString:SearchPopoverIdentifier]) {
// We can reach this code during window shutdown. We only want to toggle
// showPopover if we are in a normal running state.
if (!mTouchBarHelper) {
return;
}
bool urlbarIsFocused = false;
mTouchBarHelper->GetIsUrlbarFocused(&urlbarIsFocused);
if (urlbarIsFocused) {
Expand Down

0 comments on commit 4a2116b

Please sign in to comment.