plugins: fix hook/attr name collision in close()

Revealer plugin has method "password_dialog"
"password_dialog" is also a hook name, but revealer.password_dialog is not a hook
This commit is contained in:
SomberNight 2018-12-19 02:10:47 +01:00
parent fa33d1880c
commit ba33bc4ad8
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9

View File

@ -251,11 +251,16 @@ class BasePlugin(PrintError):
def close(self):
# remove self from hooks
for k in dir(self):
if k in hook_names:
l = hooks.get(k, [])
l.remove((self, getattr(self, k)))
hooks[k] = l
for attr_name in dir(self):
if attr_name in hook_names:
# found attribute in self that is also the name of a hook
l = hooks.get(attr_name, [])
try:
l.remove((self, getattr(self, attr_name)))
except ValueError:
# maybe attr name just collided with hook name and was not hook
continue
hooks[attr_name] = l
self.parent.close_plugin(self)
self.on_close()