← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/bugfixes24 into lp:openlp

 

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

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1490996 in OpenLP: "Presentation remains in background when sending video live on top of presentation"
  https://bugs.launchpad.net/openlp/+bug/1490996
  Bug #1491998 in OpenLP: "Playing file with unicode chars in filename with VLC on windows causes traceback"
  https://bugs.launchpad.net/openlp/+bug/1491998

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/bugfixes24/+merge/270538

Make the fix for bug 1473632 work on more linux distros.
Make sure presentations is closed correctly. Fixes bug 1490996. Test included.
Fix crash with VLC on windows with unicode chars in filename. Fixes bug 1491998.

-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/bugfixes24 into lp:openlp.
=== modified file 'openlp/core/ui/media/vendor/vlc.py'
--- openlp/core/ui/media/vendor/vlc.py	2014-06-26 07:41:22 +0000
+++ openlp/core/ui/media/vendor/vlc.py	2015-09-09 13:53:09 +0000
@@ -60,7 +60,7 @@
         """Translate string or bytes to bytes.
         """
         if isinstance(s, str):
-            return bytes(s, sys.getfilesystemencoding())
+            return s.encode()
         else:
             return s
 

=== modified file 'openlp/core/ui/media/vlcplayer.py'
--- openlp/core/ui/media/vlcplayer.py	2015-08-26 21:37:23 +0000
+++ openlp/core/ui/media/vlcplayer.py	2015-09-09 13:53:09 +0000
@@ -104,7 +104,11 @@
 if is_linux() and 'nose' not in sys.argv[0] and get_vlc():
     import ctypes
     try:
-        x11 = ctypes.cdll.LoadLibrary('libX11.so')
+        try:
+            x11 = ctypes.cdll.LoadLibrary('libX11.so.6')
+        except OSError:
+            # If libx11.so.6 was not found, fallback to more generic libx11.so
+            x11 = ctypes.cdll.LoadLibrary('libX11.so')
         x11.XInitThreads()
     except:
         log.exception('Failed to run XInitThreads(), VLC might not work properly!')

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2015-05-31 06:40:37 +0000
+++ openlp/core/ui/slidecontroller.py	2015-09-09 13:53:09 +0000
@@ -902,7 +902,8 @@
             # This avoids the service theme/desktop flashing on screen
             # However opening a new item of the same type will automatically
             # close the previous, so make sure we don't close the new one.
-            if old_item.is_command() and not service_item.is_command():
+            if old_item.is_command() and not service_item.is_command() or \
+                    old_item.is_command() and not old_item.is_media() and service_item.is_media():
                 Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
             if old_item.is_media() and not service_item.is_media():
                 self.on_media_close()

=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
--- tests/functional/openlp_core_ui/test_slidecontroller.py	2015-05-31 06:40:37 +0000
+++ tests/functional/openlp_core_ui/test_slidecontroller.py	2015-09-09 13:53:09 +0000
@@ -640,6 +640,51 @@
         mocked_preview_widget.change_slide.assert_called_once_with(7)
         mocked_slide_selected.assert_called_once_with()
 
+    @patch.object(Registry, 'execute')
+    def process_item_test(self, mocked_execute):
+        """
+        Test that presentation service-items is closed when followed by a media service-item
+        """
+        # GIVEN: A mocked presentation service item, a mocked media service item, a mocked Registry.execute
+        #        and a slide controller with many mocks.
+        mocked_pres_item = MagicMock()
+        mocked_pres_item.name = 'mocked_presentation_item'
+        mocked_pres_item.is_command.return_value = True
+        mocked_pres_item.is_media.return_value = False
+        mocked_pres_item.is_image.return_value = False
+        mocked_pres_item.from_service = False
+        mocked_pres_item.get_frames.return_value = []
+        mocked_media_item = MagicMock()
+        mocked_media_item.name = 'mocked_media_item'
+        mocked_media_item.is_command.return_value = True
+        mocked_media_item.is_media.return_value = True
+        mocked_media_item.is_image.return_value = False
+        mocked_media_item.from_service = False
+        mocked_media_item.get_frames.return_value = []
+        Registry.create()
+        mocked_main_window = MagicMock()
+        Registry().register('main_window', mocked_main_window)
+        slide_controller = SlideController(None)
+        slide_controller.service_item = mocked_pres_item
+        slide_controller.is_live = False
+        slide_controller.preview_widget = MagicMock()
+        slide_controller.enable_tool_bar = MagicMock()
+        slide_controller.on_media_start = MagicMock()
+        slide_controller.slide_selected = MagicMock()
+        slide_controller.on_stop_loop = MagicMock()
+        slide_controller.info_label = MagicMock()
+        slide_controller.display = MagicMock()
+        slide_controller.split = 0
+        slide_controller.type_prefix = 'test'
+
+        # WHEN: _process_item is called
+        slide_controller._process_item(mocked_media_item, 0)
+
+        # THEN: Registry.execute should have been called to stop the presentation
+        self.assertEqual(3, mocked_execute.call_count, 'Execute should have been called 3 times')
+        self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
+                         'The presentation should have been stopped.')
+
 
 class TestInfoLabel(TestCase):
 


References