← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bug-892571 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bug-892571 into lp:openlp.

Requested reviews:
  Andreas Preikschat (googol)
Related bugs:
  Bug #892571 in OpenLP: "Service Manager Keys do mad things"
  https://bugs.launchpad.net/openlp/+bug/892571

For more details, see:
https://code.launchpad.net/~trb143/openlp/bug-892571/+merge/83658

Stop keyboard floods getting the slide controller and service manager out of set.
Key presses are only accepted when the previous updates have happened.

To Test set preview next song to on.
Add 5 songs to service manager 
Select the first one.
Press the right arrow key fast.
-- 
https://code.launchpad.net/~trb143/openlp/bug-892571/+merge/83658
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-10-31 09:14:07 +0000
+++ openlp/core/ui/slidecontroller.py	2011-11-28 18:10:49 +0000
@@ -26,9 +26,9 @@
 ###############################################################################
 
 import logging
-import os
 import time
 import copy
+from collections import deque
 
 from PyQt4 import QtCore, QtGui
 from PyQt4.phonon import Phonon
@@ -91,6 +91,8 @@
             self.typeLabel.setText(UiStrings().Live)
             self.split = 1
             self.typePrefix = u'live'
+            self.keypress_queue = deque() 
+            self.keypress_loop = False           
         else:
             self.typeLabel.setText(UiStrings().Preview)
             self.split = 0
@@ -578,12 +580,34 @@
         self.display.videoStop()
 
     def servicePrevious(self):
-        time.sleep(0.1)
-        Receiver.send_message('servicemanager_previous_item')
+        """
+        Live event to select the previous service item from the service manager.
+        """
+        self.keypress_queue.append(u'previous')
+        self._process_queue()
+        
 
     def serviceNext(self):
-        time.sleep(0.1)
-        Receiver.send_message('servicemanager_next_item')
+        """
+        Live event to select the next service item from the service manager.
+        """
+        self.keypress_queue.append(u'next')
+        self._process_queue()
+        
+    def _process_queue(self):
+        """
+        Process the service item request queue.  The key presses can arrive 
+        faster than the processing so implement a FIFO queue. 
+        """
+        if len(self.keypress_queue):
+            while len(self.keypress_queue) and not self.keypress_loop:
+                self.keypress_loop = True                
+                if self.keypress_queue.popleft() == u'previous':
+                    Receiver.send_message('servicemanager_previous_item')                    
+                else:
+                    Receiver.send_message('servicemanager_next_item')
+            self.keypress_loop = False
+     
 
     def screenSizeChanged(self):
         """
@@ -771,7 +795,7 @@
         log.debug(u'processManagerItem live = %s' % self.isLive)
         self.onStopLoop()
         old_item = self.serviceItem
-        # take a copy not a link to the servicemeanager copy.
+        # take a copy not a link to the servicemanager copy.
         self.serviceItem = copy.copy(serviceItem)
         if old_item and self.isLive and old_item.is_capable(
             ItemCapabilities.ProvidesOwnDisplay):


Follow ups