[pygobject/wip/jfelder/template-hierarchy-fix: 1/2] gtktemplate: Change init_template to a no-op once executed



commit bd8b43a8112bb6ee239defbf73239e860e909b84
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Mar 19 21:08:00 2020 +0100

    gtktemplate: Change init_template to a no-op once executed
    
    This prevents duplicating widgets if this method is called multiple
    times.
    
    The init_template method is not directly called by the goboject
    instance_init method, the __dontuse_ginstance_init__ method is used
    instead. So this method, also needs to be turned into a no-op
    operation.
    
    Closes: #386

 gi/_gtktemplate.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gi/_gtktemplate.py b/gi/_gtktemplate.py
index efaca339..3298f355 100644
--- a/gi/_gtktemplate.py
+++ b/gi/_gtktemplate.py
@@ -99,7 +99,9 @@ def register_template(cls):
 
 
 def init_template(self, cls, base_init_template):
-    self.init_template = lambda s: None
+    # prevent init_template() from being executed multiple times
+    self.init_template = lambda: None
+    self.__dontuse_ginstance_init__ = lambda: None
 
     if self.__class__ is not cls:
         raise TypeError(


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]