Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #8446: Use correct select method on BVC when opening URLs
Browse files Browse the repository at this point in the history
A crash was introduced in #8306 due to accidentally calling the Obj-C `select(_ sender:)` method on UIResponder instead of `select(url:)`.
  • Loading branch information
kylehickinson committed Nov 20, 2023
1 parent 12c85b2 commit 6bf5ef6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2979,6 +2979,15 @@ extension BrowserViewController: ToolbarUrlActionsDelegate {
self.tabManager.addTabsForURLs(urls, zombie: false, isPrivate: tabIsPrivate)
}

public override func select(_ sender: Any?) {
#if DEBUG
if sender is URL {
assertionFailure("Wrong method called, use `select(url:)` or `select(_:action:)`")
}
#endif
super.select(sender)
}

func select(url: URL) {
select(url, action: .openInCurrentTab)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension BrowserViewController {
var components = URLComponents()
components.host = currentHost
components.scheme = url.scheme
self.select(components.url!)
self.select(url: components.url!)
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Brave/Shortcuts/ActivityShortcutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public class ActivityShortcutManager: NSObject {
} else {
let controller = NewsSettingsViewController(dataSource: bvc.feedDataSource, openURL: { url in
bvc.dismiss(animated: true)
bvc.select(url)
bvc.select(url: url)
})
controller.viewDidDisappear = {
if Preferences.Review.braveNewsCriteriaPassed.value {
Expand Down

0 comments on commit 6bf5ef6

Please sign in to comment.