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:
@@ -251,11 +251,16 @@ class BasePlugin(PrintError):
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
# remove self from hooks
|
# remove self from hooks
|
||||||
for k in dir(self):
|
for attr_name in dir(self):
|
||||||
if k in hook_names:
|
if attr_name in hook_names:
|
||||||
l = hooks.get(k, [])
|
# found attribute in self that is also the name of a hook
|
||||||
l.remove((self, getattr(self, k)))
|
l = hooks.get(attr_name, [])
|
||||||
hooks[k] = l
|
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.parent.close_plugin(self)
|
||||||
self.on_close()
|
self.on_close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user