Skip to content

fix: Don't crash when removing tabs#2206

Merged
nikclayton merged 1 commit into
pachli:mainfrom
nikclayton:tab-crash
Apr 1, 2026
Merged

fix: Don't crash when removing tabs#2206
nikclayton merged 1 commit into
pachli:mainfrom
nikclayton:tab-crash

Conversation

@nikclayton

Copy link
Copy Markdown
Contributor

Removing a tab notified the adapter that tabs 0..tabs.size had changed, but tabs.size was the new size, not the old size. So deleting a tab from the end could cause the adapter to assume the previous end tab was still present. Fix that by calling notifyDataSetChanged().

To guard against the tab selection listener being called with a tab position that no longer exists, use getOrNull to fetch the tab data, ignoring the case when the tab does not exist.

Removing a tab notified the adapter that tabs 0..tabs.size had changed, but
tabs.size was the new size, not the old size. So deleting a tab from the end
could cause the adapter to assume the previous end tab was still present.
Fix that by calling `notifyDataSetChanged()`.

To guard against the tab selection listener being called with a tab position
that no longer exists, use `getOrNull` to fetch the tab data, ignoring the
case when the tab does not exist.
@nikclayton nikclayton merged commit 4bcc25b into pachli:main Apr 1, 2026
28 checks passed
@nikclayton nikclayton deleted the tab-crash branch April 1, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant