forked from openlp/openlp
Remove the registered functions instead of overwriting
This commit is contained in:
parent
1c71efc532
commit
af4715dc3c
@ -105,7 +105,7 @@ class Registry(object):
|
|||||||
if key in self.service_list:
|
if key in self.service_list:
|
||||||
del self.service_list[key]
|
del self.service_list[key]
|
||||||
|
|
||||||
def register_function(self, event, function, overwrite=False):
|
def register_function(self, event, function):
|
||||||
"""
|
"""
|
||||||
Register an event and associated function to be called
|
Register an event and associated function to be called
|
||||||
|
|
||||||
@ -113,9 +113,8 @@ class Registry(object):
|
|||||||
will/may need to respond to a single action and the caller does not need to understand or know about the
|
will/may need to respond to a single action and the caller does not need to understand or know about the
|
||||||
recipients.
|
recipients.
|
||||||
:param function: The function to be called when the event happens.
|
:param function: The function to be called when the event happens.
|
||||||
:param overwrite: There should only be one function with the registred name.
|
|
||||||
"""
|
"""
|
||||||
if not overwrite and event in self.functions_list:
|
if event in self.functions_list:
|
||||||
self.functions_list[event].append(function)
|
self.functions_list[event].append(function)
|
||||||
else:
|
else:
|
||||||
self.functions_list[event] = [function]
|
self.functions_list[event] = [function]
|
||||||
@ -127,10 +126,6 @@ class Registry(object):
|
|||||||
:param event: The function description..
|
:param event: The function description..
|
||||||
:param function: The function to be called when the event happens.
|
:param function: The function to be called when the event happens.
|
||||||
"""
|
"""
|
||||||
if not self.running_under_test:
|
|
||||||
trace_error_handler(log)
|
|
||||||
log.error('Invalid Method call for key %s' % event)
|
|
||||||
raise KeyError('Invalid Method call for key %s' % event)
|
|
||||||
if event in self.functions_list:
|
if event in self.functions_list:
|
||||||
self.functions_list[event].remove(function)
|
self.functions_list[event].remove(function)
|
||||||
|
|
||||||
|
@ -153,9 +153,20 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||||
self.set_transparency(False)
|
self.set_transparency(False)
|
||||||
if self.is_live:
|
if self.is_live:
|
||||||
Registry().register_function('live_display_hide', self.hide_display, True)
|
Registry().register_function('live_display_hide', self.hide_display)
|
||||||
Registry().register_function('live_display_show', self.show_display, True)
|
Registry().register_function('live_display_show', self.show_display)
|
||||||
Registry().register_function('update_display_css', self.css_changed, True)
|
Registry().register_function('update_display_css', self.css_changed)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
"""
|
||||||
|
Remove registered function on close.
|
||||||
|
"""
|
||||||
|
if self.is_live:
|
||||||
|
Registry().remove_function('live_display_hide', self.hide_display)
|
||||||
|
Registry().remove_function('live_display_show', self.show_display)
|
||||||
|
Registry().remove_function('update_display_css', self.css_changed)
|
||||||
|
super().close()
|
||||||
|
|
||||||
|
|
||||||
def set_transparency(self, enabled):
|
def set_transparency(self, enabled):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user