From e45be1a50fd79c1c9cb97717641f61f494314d31 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 1 Oct 2018 23:00:25 -0700 Subject: [PATCH] Fixed issue where screens were being loaded twice; Fixed an issue where an underlying C++ object was being deleted before the Python object was finished with it --- openlp/core/display/screens.py | 20 ++++++++++++++++---- openlp/core/ui/screenstab.py | 22 +++++++++++----------- setup.cfg | 4 ++-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/openlp/core/display/screens.py b/openlp/core/display/screens.py index 60a72a6b2..0112755a1 100644 --- a/openlp/core/display/screens.py +++ b/openlp/core/display/screens.py @@ -49,7 +49,7 @@ class Screen(object): :param bool is_primary: Whether or not this screen is the primary screen :param bool is_display: Whether or not this screen should be used to display lyrics """ - self.number = number + self.number = int(number) self.geometry = geometry self.custom_geometry = None self.is_primary = is_primary @@ -66,6 +66,12 @@ class Screen(object): name = '{name} ({primary})'.format(name=name, primary=translate('OpenLP.ScreenList', 'primary')) return name + def __repr__(self): + """ + Return a string representation of the object + """ + return '<{screen}>'.format(screen=self) + @property def display_geometry(self): """ @@ -124,12 +130,16 @@ class Screen(object): :param dict screen_dict: The dictionary which we want to apply to the screen """ - self.number = screen_dict['number'] + self.number = int(screen_dict['number']) self.is_display = screen_dict['is_display'] self.is_primary = screen_dict['is_primary'] - self.geometry = QtCore.QRect(**screen_dict['geometry']) + self.geometry = QtCore.QRect(screen_dict['geometry']['x'], screen_dict['geometry']['y'], + screen_dict['geometry']['width'], screen_dict['geometry']['height']) if 'display_geometry' in screen_dict: - self.display_geometry = QtCore.QRect(**screen_dict['display_geometry']) + self.display_geometry = QtCore.QRect(screen_dict['display_geometry']['x'], + screen_dict['display_geometry']['y'], + screen_dict['display_geometry']['width'], + screen_dict['display_geometry']['height']) class ScreenList(object): @@ -222,6 +232,8 @@ class ScreenList(object): Settings.extend_default_settings(screen_settings) screen_settings = Settings().value('core/screens') for number, screen_dict in screen_settings.items(): + # Sometimes this loads as a string instead of an int + number = int(number) if self.has_screen(number): self[number].update(screen_dict) else: diff --git a/openlp/core/ui/screenstab.py b/openlp/core/ui/screenstab.py index b61d00a09..f747c4531 100644 --- a/openlp/core/ui/screenstab.py +++ b/openlp/core/ui/screenstab.py @@ -81,6 +81,7 @@ class ScreensTab(SettingsTab): super(ScreensTab, self).__init__(parent, 'Screens', screens_translated) self.settings_section = 'core' self.current_screen = None + self.identify_labels = [] def setup_ui(self): """ @@ -262,11 +263,18 @@ class ScreensTab(SettingsTab): # On save update the screens as well self.settings_form.register_post_process('config_screen_changed') + @QtCore.pyqtSlot() + def _on_identify_timer_shot(self): + for label in self.identify_labels: + label.hide() + label.setParent(None) + label.deleteLater() + self.identify_labels = [] + def on_identify_button_clicked(self): """ Display a widget on every screen for 5 seconds """ - labels = [] for screen in self.screens: label = QtWidgets.QLabel(None) label.setAlignment(QtCore.Qt.AlignCenter) @@ -278,17 +286,9 @@ class ScreensTab(SettingsTab): label.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.WindowDoesNotAcceptFocus) label.show() - labels.append(label) + self.identify_labels.append(label) - @QtCore.pyqtSlot() - def _close_label(): - label.hide() - if label in labels: - labels.remove(label) - label.setParent(None) - label.deleteLater() - - QtCore.QTimer.singleShot(3000, _close_label) + QtCore.QTimer.singleShot(3000, self._on_identify_timer_shot) def on_screen_button_clicked(self): """ diff --git a/setup.cfg b/setup.cfg index 223e5c7c2..419a7d946 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,12 +5,12 @@ [pep8] exclude=resources.py,vlc.py max-line-length = 120 -ignore = E402 +ignore = E402,E722,W503,W504 [flake8] exclude=resources.py,vlc.py max-line-length = 120 -ignore = E402 +ignore = E402,E722,W503,W504 [pycodestyle] exclude = resources.py,vlc.py