I'm using Juce v3.2.0 on Mac (though this bug should occur in Windows too). I checked the tip and the code is the same there.
void TabbedButtonBar::removeTab (const int tabIndex, const bool animate)
{
const int oldIndex = currentTabIndex;
if (tabIndex == currentTabIndex)
setCurrentTabIndex (-1);
tabs.remove (tabIndex);
setCurrentTabIndex (oldIndex);
updateTabPositions (animate);
}
The value for currentTabIndex becomes bad when a tab before the current one is removed. For example, if there's four tabs and the fourth one is selected, currentTabIndex = 3.
Remove tab 1. currentTabIndex will still be 3, even though that's not a valid index with three tabs.
Remove (what is now) tab 1. currentTabIndex = 3 still, with two tabs.
Visually, the last tab stays selected, so there's no external indication that currentTabIndex is bad. But code that calls getCurrentTabIndex() will get bad values (which is how I found this).
Thanks
Marc
