From 46a9098305dd981f6ef04bb24193bcb132a5a2de Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 27 Oct 2023 13:35:19 +1000 Subject: [PATCH] Avoid duplicate tabs when logging out/in --- koordinates/gui/explore_tab_bar.py | 8 ++++++++ koordinates/gui/filter_widget.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/koordinates/gui/explore_tab_bar.py b/koordinates/gui/explore_tab_bar.py index 793df08..cf71d07 100644 --- a/koordinates/gui/explore_tab_bar.py +++ b/koordinates/gui/explore_tab_bar.py @@ -225,6 +225,14 @@ def _explore_sections_retrieved(self, sections: List[ExploreSection]): if sip.isdeleted(self): return + # clear out old explore section tabs + for i in range(self.count()-1, -1, -1): + if self.tabData(i) not in ( + StandardExploreModes.Browse, + StandardExploreModes.Publishers + ): + self.removeTab(i) + for section in sections: if section.slug == 'popular': # special case for popular, should always be first tab diff --git a/koordinates/gui/filter_widget.py b/koordinates/gui/filter_widget.py index 5c63a7a..4927858 100644 --- a/koordinates/gui/filter_widget.py +++ b/koordinates/gui/filter_widget.py @@ -148,6 +148,12 @@ def _explore_sections_retrieved(self, sections: List[ExploreSection]): if sip.isdeleted(self): return + # clear out old explore section tabs + for button in self.explore_buttons: + self.explore_buttons_layout.removeWidget(button) + button.deleteLater() + self.explore_buttons = [] + default_section = None for section in sections: