Unverified Commit b6c84cba authored by mathieui's avatar mathieui

Fix #3424 (fix receipts)

parent 3c8fb156
...@@ -145,7 +145,8 @@ class Tabs: ...@@ -145,7 +145,8 @@ class Tabs:
self._tab_types = defaultdict(list) self._tab_types = defaultdict(list)
self._tab_names = dict() self._tab_names = dict()
for tab in self._tabs: for tab in self._tabs:
self._tab_types[type(tab)].append(tab) for cls in _get_tab_types(tab):
self._tab_types[cls].append(tab)
self._tab_names[tab.name] = tab self._tab_names[tab.name] = tab
self._update_numbers() self._update_numbers()
...@@ -203,7 +204,8 @@ class Tabs: ...@@ -203,7 +204,8 @@ class Tabs:
else: else:
tab.nb = self._tabs[-1].nb + 1 tab.nb = self._tabs[-1].nb + 1
self._tabs.append(tab) self._tabs.append(tab)
self._tab_types[type(tab)].append(tab) for cls in _get_tab_types(tab):
self._tab_types[cls].append(tab)
self._tab_names[tab.name] = tab self._tab_names[tab.name] = tab
def delete(self, tab: tabs.Tab, gap=False): def delete(self, tab: tabs.Tab, gap=False):
...@@ -218,7 +220,8 @@ class Tabs: ...@@ -218,7 +220,8 @@ class Tabs:
is_current = tab is self.current_tab is_current = tab is self.current_tab
self._tab_types[type(tab)].remove(tab) for cls in _get_tab_types(tab):
self._tab_types[cls].remove(tab)
del self._tab_names[tab.name] del self._tab_names[tab.name]
if gap: if gap:
...@@ -338,3 +341,13 @@ class Tabs: ...@@ -338,3 +341,13 @@ class Tabs:
result = self._insert_nogaps(old_pos, new_pos) result = self._insert_nogaps(old_pos, new_pos)
self._update_numbers() self._update_numbers()
return result return result
def _get_tab_types(tab: tabs.Tab) -> List[Type[tabs.Tab]]:
"""Return all parent classes of a tab type"""
types = []
current_cls = tab.__class__
while current_cls != tabs.Tab:
types.append(current_cls)
current_cls = current_cls.__bases__[0]
return types
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment