forked from openlp/openlp
Two fixes:
- Fix bug #1386896 by catching the OSError on Mac OS X and just ignoring it - Found a potential bug where the settings form was canceled, with one or more inactive plugins - Wrote a test for the above settings form bug Fixes: https://launchpad.net/bugs/1386896
This commit is contained in:
parent
d029745007
commit
69873c0db3
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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')
|
Loading…
Reference in New Issue
Block a user