Fix problem in FunctionDispatcher where it hangs if calling thread == called thread.

This commit is contained in:
Charles Haley 2011-06-11 20:53:01 +01:00
parent 0338744cb8
commit 07b12774b4

View File

@ -305,8 +305,11 @@ 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()
self.calling_thread = QThread.currentThread()
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
if self.calling_thread == QThread.currentThread():
return self.func(*args, **kwargs)
with self.lock: with self.lock:
self.dispatch_signal.emit(self.q, args, kwargs) self.dispatch_signal.emit(self.q, args, kwargs)
res = self.q.get() res = self.q.get()