← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/23bugfixes2 into lp:openlp

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/23bugfixes2 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1490508 in OpenLP: "Powerpoint / object has no attribute 'slidenumber'"
  https://bugs.launchpad.net/openlp/+bug/1490508

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/23bugfixes2/+merge/285281

More workarounds for bug 1531319.
If presentation loading fails, set slidenumber to 0 to avoid a later error. Fixes bug 1490508. Added test.
Use the chosen encoding when importing from easyworship db.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/23bugfixes2 into lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2016-01-22 21:33:20 +0000
+++ openlp/core/ui/maindisplay.py	2016-02-06 20:37:37 +0000
@@ -326,6 +326,9 @@
             else:
                 self.setVisible(False)
                 self.setGeometry(self.screen['size'])
+        # Workaround for bug #1531319, should not be needed with PyQt 5.6.
+        if is_win():
+            self.shake_web_view()
 
     def direct_image(self, path, background):
         """
@@ -395,8 +398,17 @@
             # Wait for the fade to finish before geting the preview.
             # Important otherwise preview will have incorrect text if at all!
             if self.service_item.theme_data and self.service_item.theme_data.display_slide_transition:
+                # Workaround for bug #1531319, should not be needed with PyQt 5.6.
+                if is_win():
+                    fade_shake_timer = QtCore.QTimer(self)
+                    fade_shake_timer.setInterval(25)
+                    fade_shake_timer.timeout.connect(self.shake_web_view)
+                    fade_shake_timer.start()
                 while not self.frame.evaluateJavaScript('show_text_completed()'):
                     self.application.process_events()
+                # Workaround for bug #1531319, should not be needed with PyQt 5.6.
+                if is_win():
+                    fade_shake_timer.stop()
         # Wait for the webview to update before getting the preview.
         # Important otherwise first preview will miss the background !
         while not self.web_loaded:
@@ -493,6 +505,9 @@
             if self.isHidden():
                 self.setVisible(True)
                 self.web_view.setVisible(True)
+            # Workaround for bug #1531319, should not be needed with PyQt 5.6.
+            if is_win():
+                self.shake_web_view()
         self.hide_mode = mode
 
     def show_display(self):
@@ -511,6 +526,9 @@
         # Trigger actions when display is active again.
         if self.is_live:
             Registry().execute('live_display_active')
+            # Workaround for bug #1531319, should not be needed with PyQt 5.6.
+            if is_win():
+                self.shake_web_view()
 
     def _hide_mouse(self):
         """

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2016-01-22 21:33:20 +0000
+++ openlp/core/ui/slidecontroller.py	2016-02-06 20:37:37 +0000
@@ -1101,9 +1101,6 @@
                         self.display.image(to_display)
                     # reset the store used to display first image
                     self.service_item.bg_image_bytes = None
-                # Workaround for bug #1531319, should not be needed with PyQt 5.6.
-                if self.is_live and is_win():
-                    self.display.shake_web_view()
             self.selected_row = row
             self.update_preview()
             self.preview_widget.change_slide(row)
@@ -1128,8 +1125,8 @@
         self.log_debug('update_preview %s ' % self.screens.current['primary'])
         if self.service_item and self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
             # Grab now, but try again in a couple of seconds if slide change is slow
-            QtCore.QTimer.singleShot(0.5, self.grab_maindisplay)
-            QtCore.QTimer.singleShot(2.5, self.grab_maindisplay)
+            QtCore.QTimer.singleShot(500, self.grab_maindisplay)
+            QtCore.QTimer.singleShot(2500, self.grab_maindisplay)
         else:
             self.slide_image = self.display.preview()
             self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2016-01-12 20:14:04 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2016-02-06 20:37:37 +0000
@@ -63,6 +63,7 @@
         if not self.doc.load_presentation():
             # Display error message to user
             # Inform slidecontroller that the action failed?
+            self.doc.slidenumber = 0
             return
         self.doc.slidenumber = slide_no
         self.hide_mode = hide_mode

=== modified file 'openlp/plugins/songs/lib/importers/easyworship.py'
--- openlp/plugins/songs/lib/importers/easyworship.py	2015-12-31 22:46:06 +0000
+++ openlp/plugins/songs/lib/importers/easyworship.py	2016-02-06 20:37:37 +0000
@@ -292,7 +292,7 @@
                 raw_record = db_file.read(record_size)
                 self.fields = self.record_structure.unpack(raw_record)
                 self.set_defaults()
-                self.title = self.get_field(fi_title).decode('unicode-escape')
+                self.title = self.get_field(fi_title).decode(self.encoding)
                 # Get remaining fields.
                 copy = self.get_field(fi_copy)
                 admin = self.get_field(fi_admin)
@@ -300,16 +300,16 @@
                 authors = self.get_field(fi_author)
                 words = self.get_field(fi_words)
                 if copy:
-                    self.copyright = copy.decode('unicode-escape')
+                    self.copyright = copy.decode(self.encoding)
                 if admin:
                     if copy:
                         self.copyright += ', '
                     self.copyright += translate('SongsPlugin.EasyWorshipSongImport',
-                                                'Administered by %s') % admin.decode('unicode-escape')
+                                                'Administered by %s') % admin.decode(self.encoding)
                 if ccli:
-                    self.ccli_number = ccli.decode('unicode-escape')
+                    self.ccli_number = ccli.decode(self.encoding)
                 if authors:
-                    authors = authors.decode('unicode-escape')
+                    authors = authors.decode(self.encoding)
                 else:
                     authors = ''
                 # Set the SongImport object members.
@@ -497,7 +497,7 @@
         bytes = self.get_bytes(pos, length)
         mask = '<' + str(length) + 's'
         byte_str, = struct.unpack(mask, bytes)
-        return byte_str.decode('unicode-escape').replace('\0', '').strip()
+        return byte_str.decode(self.encoding).replace('\0', '').strip()
 
     def get_i16(self, pos):
         """

=== modified file 'tests/functional/openlp_plugins/presentations/test_messagelistener.py'
--- tests/functional/openlp_plugins/presentations/test_messagelistener.py	2016-01-13 20:56:55 +0000
+++ tests/functional/openlp_plugins/presentations/test_messagelistener.py	2016-02-06 20:37:37 +0000
@@ -26,6 +26,7 @@
 
 from openlp.core.common import Registry
 from openlp.plugins.presentations.lib.mediaitem import MessageListener, PresentationMediaItem
+from openlp.plugins.presentations.lib.messagelistener import Controller
 from tests.functional import patch, MagicMock
 from tests.helpers.testmixin import TestMixin
 
@@ -124,3 +125,26 @@
 
         # THEN: The handler should be set to None
         self.assertIsNone(ml.handler, 'The handler should be None')
+
+
+class TestController(TestCase, TestMixin):
+    """
+    Test the Presentation Controller.
+    """
+
+    def add_handler_failure_test(self):
+        """
+        Test that add_handler does set doc.slidenumber to 0 in case filed loading
+        """
+        # GIVEN: A Controller, a mocked doc-controller
+        controller = Controller(True)
+        mocked_doc_controller = MagicMock()
+        mocked_doc = MagicMock()
+        mocked_doc.load_presentation.return_value = False
+        mocked_doc_controller.add_document.return_value = mocked_doc
+
+        # WHEN: calling add_handler that fails
+        controller.add_handler(mocked_doc_controller, MagicMock(), True, 0)
+
+        # THEN: slidenumber should be 0
+        self.assertEqual(controller.doc.slidenumber, 0, 'doc.slidenumber should be 0')


Follow ups