Insert timeout on acquiring lock in slidecontroller to avoid hang. Fixes bug 1413324.

Fixes: https://launchpad.net/bugs/1413324
This commit is contained in:
Tomas Groth 2015-03-18 22:02:51 +00:00
parent b3fd23da59
commit 7e406e7005
1 changed files with 7 additions and 2 deletions

View File

@ -1069,8 +1069,13 @@ class SlideController(DisplayController, RegistryProperties):
:param start:
"""
# Only one thread should be in here at the time. If already locked just skip, since the update will be
# done by the thread holding the lock. If it is a "start" slide, we must wait for the lock.
if not self.slide_selected_lock.acquire(start):
# done by the thread holding the lock. If it is a "start" slide, we must wait for the lock, but only for 0.2
# seconds, since we don't want to cause a deadlock
timeout = 0.2 if start else -1
if not self.slide_selected_lock.acquire(start, timeout):
if start:
self.log_debug('Could not get lock in slide_selected after waiting %f, skip to avoid deadlock.'
% timeout)
return
row = self.preview_widget.current_slide_number()
self.selected_row = 0