From bfce3db90283df7ff2dac1309faf6e9eb9a27bf7 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 21 Jan 2022 07:49:55 +0000 Subject: [PATCH] A few bug fixes --- openlp/core/ui/serviceitemeditform.py | 4 +++- openlp/core/ui/servicemanager.py | 6 +++++- tests/openlp_core/ui/test_serviceitemeditform.py | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index a515596e7..2e05ca0f2 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -62,7 +62,9 @@ class ServiceItemEditForm(QtWidgets.QDialog, Ui_ServiceItemEditDialog, RegistryP # self.data is only true for images self.item.slides = [] for item in self.item_list: - self.item.add_from_image(item['path'], item['title']) + thumb = item.get('thumbnail', None) + file_hash = item.get('file_hash', None) + self.item.add_from_image(item['path'], item['title'], thumb, file_hash) return self.item def load_data(self): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cb4c6a9c1..16f9a151f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -762,7 +762,11 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi """ # If the file_path is a string, this method will fail. Typecase to Path file_path = Path(file_path) - if not file_path.exists(): + try: + if not file_path.exists(): + return False + except OSError: + # if the filename, directory name, or volume label syntax is incorrect it can cause an exception return False service_data = None self.application.set_busy_cursor() diff --git a/tests/openlp_core/ui/test_serviceitemeditform.py b/tests/openlp_core/ui/test_serviceitemeditform.py index 4cb11a284..fc7a3bccc 100644 --- a/tests/openlp_core/ui/test_serviceitemeditform.py +++ b/tests/openlp_core/ui/test_serviceitemeditform.py @@ -84,8 +84,8 @@ def test_get_service_item(form): assert item is form.item, 'The returned item should be form.item' # FYI: list should be empty because it was cleared but never filled again due to the mock assert item.slides == [], 'The list of slides should have been cleared' - assert item.add_from_image.call_args_list == [call('../slide1.jpg', 'slide1.jpg'), - call('../slide2.jpg', 'slide2.jpg')] + assert item.add_from_image.call_args_list == [call('../slide1.jpg', 'slide1.jpg', None, None), + call('../slide2.jpg', 'slide2.jpg', None, None)] @patch('openlp.core.ui.serviceitemeditform.QtWidgets.QListWidgetItem')