Ensure Tag Browser recount is always called in the GUI thread.

This commit is contained in:
Kovid Goyal 2010-04-03 15:21:53 +05:30
parent 2f36b3523f
commit 64c423ba08
3 changed files with 10 additions and 2 deletions

View File

@ -592,6 +592,11 @@ def is_ok_to_use_qt():
gui_thread = QThread.currentThread()
return gui_thread is QThread.currentThread()
def is_gui_thread():
global gui_thread
return gui_thread is QThread.currentThread()
def find_forms(srcdir):
base = os.path.join(srcdir, 'calibre', 'gui2')
forms = []

View File

@ -12,7 +12,7 @@ from itertools import izip
from PyQt4.Qt import Qt, QTreeView, QApplication, \
QFont, SIGNAL, QSize, QIcon, QPoint, \
QAbstractItemModel, QVariant, QModelIndex
from calibre.gui2 import config, NONE
from calibre.gui2 import config, NONE, is_gui_thread, Dispatcher
from calibre.utils.search_query_parser import saved_searches
from calibre.library.database2 import Tag
@ -54,6 +54,9 @@ class TagsView(QTreeView):
self.model().clear_state()
def recount(self, *args):
if not is_gui_thread():
# Re-call in GUI thread
return Dispatcher(self.recount)(*args)
ci = self.currentIndex()
if not ci.isValid():
ci = self.indexAt(QPoint(10, 10))

View File

@ -536,7 +536,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.connect(self.library_view.model(),
SIGNAL('count_changed(int)'), self.location_view.count_changed)
self.connect(self.library_view.model(), SIGNAL('count_changed(int)'),
self.tags_view.recount)
self.tags_view.recount, Qt.QueuedConnection)
self.connect(self.search, SIGNAL('cleared()'), self.tags_view_clear)
self.connect(self.saved_search, SIGNAL('changed()'), self.tags_view.recount, Qt.QueuedConnection)
if not gprefs.get('quick_start_guide_added', False):