From 7e406e700570d019aeff1907b1c8d2c05688af2b Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 18 Mar 2015 22:02:51 +0000 Subject: [PATCH] Insert timeout on acquiring lock in slidecontroller to avoid hang. Fixes bug 1413324. Fixes: https://launchpad.net/bugs/1413324 --- openlp/core/ui/slidecontroller.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 645940fe6..22fd0f4b3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -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