From 1c71efc532f2464e897b3818f8a23d6bc94a8708 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 1 Dec 2014 15:08:13 +0000 Subject: [PATCH] Allow overwriting functions in registry, and use it when registring MainDisplay. Fixes bug 1397287 Fixes: https://launchpad.net/bugs/1397287 --- openlp/core/common/registry.py | 5 +++-- openlp/core/ui/maindisplay.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 218325823..70c2fe3bd 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -105,7 +105,7 @@ class Registry(object): if key in self.service_list: del self.service_list[key] - def register_function(self, event, function): + def register_function(self, event, function, overwrite=False): """ Register an event and associated function to be called @@ -113,8 +113,9 @@ class Registry(object): will/may need to respond to a single action and the caller does not need to understand or know about the recipients. :param function: The function to be called when the event happens. + :param overwrite: There should only be one function with the registred name. """ - if event in self.functions_list: + if not overwrite and event in self.functions_list: self.functions_list[event].append(function) else: self.functions_list[event] = [function] diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f9f00a235..ceb94a2a9 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -153,9 +153,9 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.set_transparency(False) if self.is_live: - Registry().register_function('live_display_hide', self.hide_display) - Registry().register_function('live_display_show', self.show_display) - Registry().register_function('update_display_css', self.css_changed) + Registry().register_function('live_display_hide', self.hide_display, True) + Registry().register_function('live_display_show', self.show_display, True) + Registry().register_function('update_display_css', self.css_changed, True) def set_transparency(self, enabled): """