diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 7e8acc318..de0ff57ba 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -33,7 +33,6 @@ from datetime import datetime from distutils.version import LooseVersion import logging import os -import sys import threading from PyQt4 import QtGui @@ -55,6 +54,8 @@ except OSError as e: if is_win(): if not isinstance(e, WindowsError) and e.winerror != 126: raise + elif is_macosx(): + pass else: raise diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 581f5c18c..f3292c258 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -57,6 +57,11 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): self.processes = [] self.setupUi(self) self.setting_list_widget.currentRowChanged.connect(self.list_item_changed) + self.general_tab = None + self.themes_tab = None + self.projector_tab = None + self.advanced_tab = None + self.player_tab = None def exec_(self): """ @@ -125,8 +130,18 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): Process the form saving the settings """ self.processes = [] - for tabIndex in range(self.stacked_layout.count()): - self.stacked_layout.widget(tabIndex).cancel() + # Same as accept(), we need to loop over the visible tabs, and skip the inactive ones + for item_index in range(self.setting_list_widget.count()): + # Get the list item + list_item = self.setting_list_widget.item(item_index) + if not list_item: + continue + # Now figure out if there's a tab for it, and save the tab. + plugin_name = list_item.data(QtCore.Qt.UserRole) + for tab_index in range(self.stacked_layout.count()): + tab_widget = self.stacked_layout.widget(tab_index) + if tab_widget.tab_title == plugin_name: + tab_widget.cancel() return QtGui.QDialog.reject(self) def bootstrap_post_set_up(self): diff --git a/tests/functional/openlp_core_ui/test_settingsform.py b/tests/functional/openlp_core_ui/test_settingsform.py index 430346059..17a8b165f 100644 --- a/tests/functional/openlp_core_ui/test_settingsform.py +++ b/tests/functional/openlp_core_ui/test_settingsform.py @@ -130,3 +130,31 @@ class TestSettingsForm(TestCase): # THEN: The rest of the method should not have been called self.assertEqual(0, mocked_count.call_count, 'The count method of the stacked layout should not be called') + + def reject_with_inactive_items_test(self): + """ + Test that the reject() method works correctly when some of the plugins are inactive + """ + # GIVEN: A visible general tab and an invisible theme tab in a Settings Form + settings_form = SettingsForm(None) + general_tab = QtGui.QWidget(None) + general_tab.tab_title = 'mock-general' + general_tab.tab_title_visible = 'Mock General' + general_tab.icon_path = ':/icon/openlp-logo-16x16.png' + mocked_general_cancel = MagicMock() + general_tab.cancel = mocked_general_cancel + settings_form.insert_tab(general_tab, is_visible=True) + themes_tab = QtGui.QWidget(None) + themes_tab.tab_title = 'mock-themes' + themes_tab.tab_title_visible = 'Mock Themes' + themes_tab.icon_path = ':/icon/openlp-logo-16x16.png' + mocked_theme_cancel = MagicMock() + themes_tab.cancel = mocked_theme_cancel + settings_form.insert_tab(themes_tab, is_visible=False) + + # WHEN: The reject() method is called + settings_form.reject() + + # THEN: The general tab's cancel() method should have been called, but not the themes tab + mocked_general_cancel.assert_called_with() + self.assertEqual(0, mocked_theme_cancel.call_count, 'The Themes tab\'s cancel() should not have been called') \ No newline at end of file