[gedit/libgpe] Fix fallback method usage in python to avoid infinite loop.
- From: Steve Frécinaux <sfre src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gedit/libgpe] Fix fallback method usage in python to avoid infinite loop.
- Date: Wed, 4 Nov 2009 20:06:47 +0000 (UTC)
commit e8946f420430e82dcc00df693b598688c27b006e
Author: Steve Frécinaux <code istique net>
Date: Wed Nov 4 19:22:43 2009 +0100
Fix fallback method usage in python to avoid infinite loop.
If you implement do_activate but chain up to the parent, then you could
have ended up in an infinite loop as the plugin methods without the do_
prefix are actually present in gedit.Plugin and end up calling the do_
method. This fixes it.
bindings/python/__init__.py | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/bindings/python/__init__.py b/bindings/python/__init__.py
index acbf263..bec07de 100644
--- a/bindings/python/__init__.py
+++ b/bindings/python/__init__.py
@@ -23,20 +23,18 @@ from gedit._gedit import *
import gobject
from gedit import _gedit
-class Plugin(_gedit.Plugin):
- def do_activate(self, window):
- if hasattr(self, 'activate'):
- self.activate(window)
+def _proxy_plugin_method(method_name):
+ def method(self, window):
+ child_method = getattr(self.__class__, method_name)
+ parent_method = getattr(_gedit.Plugin, method_name)
+ if child_method != parent_method:
+ return child_method(self, window)
+ return method
- def do_deactivate(self, window):
- if hasattr(self, 'deactivate'):
- self.deactivate(window)
- def do_update_ui(self, window):
- if hasattr(self, 'update_ui'):
- self.update_ui(window)
+class Plugin(_gedit.Plugin):
+ do_activate = _proxy_plugin_method('activate')
+ do_deactivate = _proxy_plugin_method('deactivate')
+ do_update_ui = _proxy_plugin_method('update_ui')
gobject.type_register(Plugin)
-
-# Make it harder to access the actual module...
-del _gedit
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]