mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression in calibre 2.0 that caused crashes when using drag and drop to re-order virtual library tabs
This commit is contained in:
parent
6d0b51f8d2
commit
072b5b885c
@ -277,6 +277,7 @@ class VLTabs(QTabBar): # {{{
|
||||
self.setMovable(True)
|
||||
self.setTabsClosable(True)
|
||||
self.gui = parent
|
||||
self.ignore_tab_changed = False
|
||||
self.currentChanged.connect(self.tab_changed)
|
||||
self.tabMoved.connect(self.tab_moved, type=Qt.QueuedConnection)
|
||||
self.tabCloseRequested.connect(self.tab_close)
|
||||
@ -292,8 +293,10 @@ class VLTabs(QTabBar): # {{{
|
||||
self.setVisible(False)
|
||||
|
||||
def tab_changed(self, idx):
|
||||
if self.ignore_tab_changed:
|
||||
return
|
||||
vl = unicode(self.tabData(idx) or '').strip() or None
|
||||
self.gui.apply_virtual_library(vl)
|
||||
self.gui.apply_virtual_library(vl, update_tabs=False)
|
||||
|
||||
def tab_moved(self, from_, to):
|
||||
self.current_db.prefs['virt_libs_order'] = [unicode(self.tabData(i) or '') for i in range(self.count())]
|
||||
@ -310,7 +313,13 @@ class VLTabs(QTabBar): # {{{
|
||||
return self.gui.current_db
|
||||
|
||||
def rebuild(self):
|
||||
self.currentChanged.disconnect(self.tab_changed)
|
||||
self.ignore_tab_changed = True
|
||||
try:
|
||||
self._rebuild()
|
||||
finally:
|
||||
self.ignore_tab_changed = False
|
||||
|
||||
def _rebuild(self):
|
||||
db = self.current_db
|
||||
vl_map = db.prefs.get('virtual_libraries', {})
|
||||
virt_libs = frozenset(vl_map)
|
||||
@ -341,7 +350,6 @@ class VLTabs(QTabBar): # {{{
|
||||
self.setCurrentIndex(all_idx if current_idx is None else current_idx)
|
||||
if current_idx is None and current_lib:
|
||||
self.setTabText(all_idx, current_lib)
|
||||
self.currentChanged.connect(self.tab_changed)
|
||||
try:
|
||||
self.tabButton(all_idx, self.RightSide).setVisible(False)
|
||||
except AttributeError:
|
||||
|
@ -421,7 +421,7 @@ class SearchRestrictionMixin(object):
|
||||
def rebuild_vl_tabs(self):
|
||||
self.vl_tabs.rebuild()
|
||||
|
||||
def apply_virtual_library(self, library=None):
|
||||
def apply_virtual_library(self, library=None, update_tabs=True):
|
||||
db = self.library_view.model().db
|
||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||
if not library:
|
||||
@ -456,6 +456,7 @@ class SearchRestrictionMixin(object):
|
||||
db.data.get_base_restriction())
|
||||
self._apply_search_restriction(db.data.get_search_restriction(),
|
||||
db.data.get_search_restriction_name())
|
||||
if update_tabs:
|
||||
self.vl_tabs.update_current()
|
||||
|
||||
def build_virtual_library_list(self, menu, handler):
|
||||
|
Loading…
x
Reference in New Issue
Block a user