This commit is contained in:
Kovid Goyal 2011-06-11 15:40:45 -06:00
parent b1979948b5
commit e819fced24

View File

@ -298,6 +298,12 @@ class FunctionDispatcher(QObject):
def __init__(self, func, queued=True, parent=None): def __init__(self, func, queued=True, parent=None):
global gui_thread global gui_thread
if gui_thread is None:
gui_thread = QThread.currentThread()
if not is_gui_thread():
raise ValueError(
'You can only create a FunctionDispatcher in the GUI thread')
QObject.__init__(self, parent) QObject.__init__(self, parent)
self.func = func self.func = func
typ = Qt.QueuedConnection typ = Qt.QueuedConnection
@ -306,8 +312,6 @@ class FunctionDispatcher(QObject):
self.dispatch_signal.connect(self.dispatch, type=typ) self.dispatch_signal.connect(self.dispatch, type=typ)
self.q = Queue.Queue() self.q = Queue.Queue()
self.lock = threading.Lock() self.lock = threading.Lock()
if gui_thread is None:
gui_thread = QThread.currentThread()
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
if is_gui_thread(): if is_gui_thread():