Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 759377f

Browse files
authored
Bug 1493707 - bug selecting a closed parent tab (#4259)
* Bug 1493707 - bug selecting a closed parent tab * add another state assertion
1 parent a870e5a commit 759377f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Client/Frontend/Browser/Tab.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Tab: NSObject {
134134
var screenshotUUID: UUID?
135135

136136
// If this tab has been opened from another, its parent will point to the tab from which it was opened
137-
var parent: Tab?
137+
weak var parent: Tab?
138138

139139
fileprivate var contentScriptManager = TabContentScriptManager()
140140
private(set) var userScriptManager: UserScriptManager?

Client/Frontend/Browser/TabManager.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class TabManager: NSObject {
194194
} else {
195195
_selectedIndex = -1
196196
}
197+
assert(_selectedIndex > -1, "Tab expected to be in `tabs`")
197198

198199
store.preserveTabs(tabs, selectedTab: selectedTab)
199200

@@ -439,7 +440,7 @@ class TabManager: NSObject {
439440
// Select the most recently visited tab, IFF it is also the parent tab of the closed tab.
440441
func selectParentTab(afterRemoving tab: Tab) -> Bool {
441442
let viableTabs = tab.isPrivate ? privateTabs : normalTabs
442-
guard let parentTab = tab.parent, parentTab != tab, !viableTabs.isEmpty else { return false }
443+
guard let parentTab = tab.parent, parentTab != tab, !viableTabs.isEmpty, viableTabs.contains(parentTab) else { return false }
443444

444445
var parentTabIsMostRecentUsed = true
445446
for candidate in viableTabs {

0 commit comments

Comments
 (0)