plugin reloading refactoring

This commit is contained in:
ingvar1995 2017-03-25 18:21:25 +03:00
parent 7cc404ce52
commit 5fea3e918d
2 changed files with 9 additions and 5 deletions

View File

@ -466,10 +466,8 @@ class MainWindow(QtGui.QMainWindow, Singleton):
def reload_plugins(self):
plugin_loader = plugin_support.PluginLoader.get_instance()
if plugin_loader is None:
return
plugin_loader.stop()
plugin_loader.load()
if plugin_loader is not None:
plugin_loader.reload()
def import_plugin(self):
import util

View File

@ -51,7 +51,8 @@ class PluginLoader(util.Singleton):
continue
for elem in dir(module):
obj = getattr(module, elem)
if inspect.isclass(obj) and hasattr(obj, 'is_plugin') and obj.is_plugin: # looking for plugin class in module
# looking for plugin class in module
if inspect.isclass(obj) and hasattr(obj, 'is_plugin') and obj.is_plugin:
print('Plugin', elem)
try: # create instance of plugin class
inst = obj(self._tox, self._profile, self._settings, self._encr)
@ -165,3 +166,8 @@ class PluginLoader(util.Singleton):
if self._plugins[key][1]:
self._plugins[key][0].close()
del self._plugins[key]
def reload(self):
print('Reloading plugins')
self.stop()
self.load()