Fix weird crash in on_tab_changed