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

Proposed by Tomas Groth
Status: Merged
Approved by: Tim Bentley
Approved revision: 2616
Merged at revision: 2616
Proposed branch: lp:~tomasgroth/openlp/23bugfixes2
Merge into: lp:openlp
Diff against target: 170 lines (+51/-11)
5 files modified
openlp/core/ui/maindisplay.py (+18/-0)
openlp/core/ui/slidecontroller.py (+2/-5)
openlp/plugins/presentations/lib/messagelistener.py (+1/-0)
openlp/plugins/songs/lib/importers/easyworship.py (+6/-6)
tests/functional/openlp_plugins/presentations/test_messagelistener.py (+24/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/23bugfixes2
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Raoul Snyman Approve
Review via email: mp+285281@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote :
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
Revision history for this message
Tim Bentley (trb143) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
326 else:326 else:
327 self.setVisible(False)327 self.setVisible(False)
328 self.setGeometry(self.screen['size'])328 self.setGeometry(self.screen['size'])
329 # Workaround for bug #1531319, should not be needed with PyQt 5.6.
330 if is_win():
331 self.shake_web_view()
329332
330 def direct_image(self, path, background):333 def direct_image(self, path, background):
331 """334 """
@@ -395,8 +398,17 @@
395 # Wait for the fade to finish before geting the preview.398 # Wait for the fade to finish before geting the preview.
396 # Important otherwise preview will have incorrect text if at all!399 # Important otherwise preview will have incorrect text if at all!
397 if self.service_item.theme_data and self.service_item.theme_data.display_slide_transition:400 if self.service_item.theme_data and self.service_item.theme_data.display_slide_transition:
401 # Workaround for bug #1531319, should not be needed with PyQt 5.6.
402 if is_win():
403 fade_shake_timer = QtCore.QTimer(self)
404 fade_shake_timer.setInterval(25)
405 fade_shake_timer.timeout.connect(self.shake_web_view)
406 fade_shake_timer.start()
398 while not self.frame.evaluateJavaScript('show_text_completed()'):407 while not self.frame.evaluateJavaScript('show_text_completed()'):
399 self.application.process_events()408 self.application.process_events()
409 # Workaround for bug #1531319, should not be needed with PyQt 5.6.
410 if is_win():
411 fade_shake_timer.stop()
400 # Wait for the webview to update before getting the preview.412 # Wait for the webview to update before getting the preview.
401 # Important otherwise first preview will miss the background !413 # Important otherwise first preview will miss the background !
402 while not self.web_loaded:414 while not self.web_loaded:
@@ -493,6 +505,9 @@
493 if self.isHidden():505 if self.isHidden():
494 self.setVisible(True)506 self.setVisible(True)
495 self.web_view.setVisible(True)507 self.web_view.setVisible(True)
508 # Workaround for bug #1531319, should not be needed with PyQt 5.6.
509 if is_win():
510 self.shake_web_view()
496 self.hide_mode = mode511 self.hide_mode = mode
497512
498 def show_display(self):513 def show_display(self):
@@ -511,6 +526,9 @@
511 # Trigger actions when display is active again.526 # Trigger actions when display is active again.
512 if self.is_live:527 if self.is_live:
513 Registry().execute('live_display_active')528 Registry().execute('live_display_active')
529 # Workaround for bug #1531319, should not be needed with PyQt 5.6.
530 if is_win():
531 self.shake_web_view()
514532
515 def _hide_mouse(self):533 def _hide_mouse(self):
516 """534 """
517535
=== 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 @@
1101 self.display.image(to_display)1101 self.display.image(to_display)
1102 # reset the store used to display first image1102 # reset the store used to display first image
1103 self.service_item.bg_image_bytes = None1103 self.service_item.bg_image_bytes = None
1104 # Workaround for bug #1531319, should not be needed with PyQt 5.6.
1105 if self.is_live and is_win():
1106 self.display.shake_web_view()
1107 self.selected_row = row1104 self.selected_row = row
1108 self.update_preview()1105 self.update_preview()
1109 self.preview_widget.change_slide(row)1106 self.preview_widget.change_slide(row)
@@ -1128,8 +1125,8 @@
1128 self.log_debug('update_preview %s ' % self.screens.current['primary'])1125 self.log_debug('update_preview %s ' % self.screens.current['primary'])
1129 if self.service_item and self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):1126 if self.service_item and self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
1130 # Grab now, but try again in a couple of seconds if slide change is slow1127 # Grab now, but try again in a couple of seconds if slide change is slow
1131 QtCore.QTimer.singleShot(0.5, self.grab_maindisplay)1128 QtCore.QTimer.singleShot(500, self.grab_maindisplay)
1132 QtCore.QTimer.singleShot(2.5, self.grab_maindisplay)1129 QtCore.QTimer.singleShot(2500, self.grab_maindisplay)
1133 else:1130 else:
1134 self.slide_image = self.display.preview()1131 self.slide_image = self.display.preview()
1135 self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())1132 self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())
11361133
=== 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 @@
63 if not self.doc.load_presentation():63 if not self.doc.load_presentation():
64 # Display error message to user64 # Display error message to user
65 # Inform slidecontroller that the action failed?65 # Inform slidecontroller that the action failed?
66 self.doc.slidenumber = 0
66 return67 return
67 self.doc.slidenumber = slide_no68 self.doc.slidenumber = slide_no
68 self.hide_mode = hide_mode69 self.hide_mode = hide_mode
6970
=== 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 @@
292 raw_record = db_file.read(record_size)292 raw_record = db_file.read(record_size)
293 self.fields = self.record_structure.unpack(raw_record)293 self.fields = self.record_structure.unpack(raw_record)
294 self.set_defaults()294 self.set_defaults()
295 self.title = self.get_field(fi_title).decode('unicode-escape')295 self.title = self.get_field(fi_title).decode(self.encoding)
296 # Get remaining fields.296 # Get remaining fields.
297 copy = self.get_field(fi_copy)297 copy = self.get_field(fi_copy)
298 admin = self.get_field(fi_admin)298 admin = self.get_field(fi_admin)
@@ -300,16 +300,16 @@
300 authors = self.get_field(fi_author)300 authors = self.get_field(fi_author)
301 words = self.get_field(fi_words)301 words = self.get_field(fi_words)
302 if copy:302 if copy:
303 self.copyright = copy.decode('unicode-escape')303 self.copyright = copy.decode(self.encoding)
304 if admin:304 if admin:
305 if copy:305 if copy:
306 self.copyright += ', '306 self.copyright += ', '
307 self.copyright += translate('SongsPlugin.EasyWorshipSongImport',307 self.copyright += translate('SongsPlugin.EasyWorshipSongImport',
308 'Administered by %s') % admin.decode('unicode-escape')308 'Administered by %s') % admin.decode(self.encoding)
309 if ccli:309 if ccli:
310 self.ccli_number = ccli.decode('unicode-escape')310 self.ccli_number = ccli.decode(self.encoding)
311 if authors:311 if authors:
312 authors = authors.decode('unicode-escape')312 authors = authors.decode(self.encoding)
313 else:313 else:
314 authors = ''314 authors = ''
315 # Set the SongImport object members.315 # Set the SongImport object members.
@@ -497,7 +497,7 @@
497 bytes = self.get_bytes(pos, length)497 bytes = self.get_bytes(pos, length)
498 mask = '<' + str(length) + 's'498 mask = '<' + str(length) + 's'
499 byte_str, = struct.unpack(mask, bytes)499 byte_str, = struct.unpack(mask, bytes)
500 return byte_str.decode('unicode-escape').replace('\0', '').strip()500 return byte_str.decode(self.encoding).replace('\0', '').strip()
501501
502 def get_i16(self, pos):502 def get_i16(self, pos):
503 """503 """
504504
=== 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 @@
2626
27from openlp.core.common import Registry27from openlp.core.common import Registry
28from openlp.plugins.presentations.lib.mediaitem import MessageListener, PresentationMediaItem28from openlp.plugins.presentations.lib.mediaitem import MessageListener, PresentationMediaItem
29from openlp.plugins.presentations.lib.messagelistener import Controller
29from tests.functional import patch, MagicMock30from tests.functional import patch, MagicMock
30from tests.helpers.testmixin import TestMixin31from tests.helpers.testmixin import TestMixin
3132
@@ -124,3 +125,26 @@
124125
125 # THEN: The handler should be set to None126 # THEN: The handler should be set to None
126 self.assertIsNone(ml.handler, 'The handler should be None')127 self.assertIsNone(ml.handler, 'The handler should be None')
128
129
130class TestController(TestCase, TestMixin):
131 """
132 Test the Presentation Controller.
133 """
134
135 def add_handler_failure_test(self):
136 """
137 Test that add_handler does set doc.slidenumber to 0 in case filed loading
138 """
139 # GIVEN: A Controller, a mocked doc-controller
140 controller = Controller(True)
141 mocked_doc_controller = MagicMock()
142 mocked_doc = MagicMock()
143 mocked_doc.load_presentation.return_value = False
144 mocked_doc_controller.add_document.return_value = mocked_doc
145
146 # WHEN: calling add_handler that fails
147 controller.add_handler(mocked_doc_controller, MagicMock(), True, 0)
148
149 # THEN: slidenumber should be 0
150 self.assertEqual(controller.doc.slidenumber, 0, 'doc.slidenumber should be 0')