From 4d1061f72309d91092b4efb11e96f3922c60afa3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 21 Jun 2013 06:16:35 +0100 Subject: [PATCH] Clean up registry for application --- openlp/core/lib/mediamanageritem.py | 12 +++-- openlp/core/lib/registry.py | 3 -- openlp/core/ui/firsttimeform.py | 12 +++-- openlp/core/ui/maindisplay.py | 12 +++-- openlp/core/ui/mainwindow.py | 15 ++++-- openlp/core/ui/media/mediaplayer.py | 12 +++-- openlp/core/ui/pluginform.py | 12 +++-- openlp/core/ui/servicemanager.py | 12 +++-- openlp/core/ui/thememanager.py | 12 +++-- openlp/core/ui/wizard.py | 12 +++-- openlp/plugins/bibles/forms/editbibleform.py | 12 +++-- openlp/plugins/bibles/lib/db.py | 12 +++-- openlp/plugins/bibles/lib/http.py | 48 ++++++++++++------- .../songs/forms/duplicatesongremovalform.py | 12 +++-- .../songs/forms/songmaintenanceform.py | 12 +++-- openlp/plugins/songs/lib/openlyricsexport.py | 12 +++-- 16 files changed, 147 insertions(+), 75 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index c3e1fa366..11565607e 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -728,10 +728,14 @@ class MediaManagerItem(QtGui.QWidget): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 7e880f1f9..cee9e0329 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -103,9 +103,6 @@ class Registry(object): ``key`` The service to be deleted. """ - if self.running_under_test is False: - log.error(u'Invalid Method call for key %s' % key) - raise KeyError(u'Invalid Method call for key %s' % key) if key in self.service_list: del self.service_list[key] diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 0f3f3cc18..d6bb59daf 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -484,10 +484,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 7069cb9b7..74cea4f1f 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -494,11 +494,15 @@ class MainDisplay(Display): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 4607c441f..6a285de4c 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1064,6 +1064,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.live_controller.display: self.live_controller.display.close() self.live_controller.display = None + if os.name == u'nt': + # Needed for Windows to stop crashes on exit + Registry.remove(u'application') def service_changed(self, reset=False, serviceName=None): """ @@ -1374,10 +1377,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index c1f060f60..d76bbef58 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -153,10 +153,14 @@ class MediaPlayer(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) \ No newline at end of file diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index dd497bd68..d54bb8b6d 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -166,10 +166,14 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 444edc814..718a66ec8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1588,10 +1588,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index be0e3bfa1..07595b4a5 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -836,10 +836,14 @@ class ThemeManager(QtGui.QWidget): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 0b142b459..0101b9d0e 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -320,10 +320,14 @@ class OpenLPWizard(QtGui.QWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index b05fb68fb..36e41eb51 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -191,10 +191,14 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 837dbec38..b8e85afaf 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -544,11 +544,15 @@ class BibleDB(QtCore.QObject, Manager): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index efab9106b..332194049 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -301,11 +301,15 @@ class BGExtract(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) @@ -377,11 +381,15 @@ class BSExtract(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) @@ -477,11 +485,15 @@ class CWExtract(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) @@ -667,11 +679,15 @@ class HTTPBible(BibleDB): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index d612a5627..0b2b2457a 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -349,10 +349,14 @@ class DuplicateSongRemovalForm(OpenLPWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 9f003b2a0..9c2d49a5d 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -525,10 +525,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def _get_application(self): """ - Adds the application to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index f9ac6ebb3..be68a55c6 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -84,10 +84,14 @@ class OpenLyricsExport(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application)