lib/bb/data_smart.py:
authorHolger Hans Peter Freyther <zecke@selfish.org>
Wed, 22 Mar 2006 16:03:39 +0000 (16:03 +0000)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Wed, 22 Mar 2006 16:03:39 +0000 (16:03 +0000)
ReAdd the handlers when unpickling the file

parse/parse_py/BBHandler.py:
Save the once added handlers in the bitbake
file.

lib/bb/data_smart.py
lib/bb/parse/parse_py/BBHandler.py

index 52f391d..93a6acf 100644 (file)
@@ -285,11 +285,20 @@ class DataSmartPackage(DataSmart):
         p = pickle.Unpickler( file("%s/%s"%(self.cache,cache_bbfile),"rb"))
         self.dict = p.load()
         self.unpickle_prep()
+
+        # compile the functions into global scope
         funcstr = self.getVar('__functions__', 0)
         if funcstr:
             comp = utils.better_compile(funcstr, "<pickled>", self.bbfile)
             utils.better_exec(comp, __builtins__, funcstr, self.bbfile)
 
+        # now add the handlers which were present
+        handlers = self.getVar('__all_handlers__', 0) or {}
+        import bb.event
+        for key in handlers.keys():
+            bb.event.register(key, handlers[key])
+
+
     def linkDataSet(self):
         if not self.parent == None:
             # assume parent is a DataSmartInstance
index 92ff6c5..a1bf980 100644 (file)
@@ -165,9 +165,15 @@ def handle(fn, d, include = 0):
             set_additional_vars(fn, d, include)
             data.update_data(d)
 
+            all_handlers = {} 
             for var in data.keys(d):
+                # try to add the handler
+                # if we added it remember the choiche
                 if data.getVarFlag(var, 'handler', d):
-                    bb.event.register(var, data.getVar(var, d))
+                    handler = data.getVar(var,d)
+                    if bb.event.register(var,handler) == bb.event.Registered:
+                        all_handlers[var] = handler
+
                     continue
 
                 if not data.getVarFlag(var, 'task', d):
@@ -181,6 +187,11 @@ def handle(fn, d, include = 0):
                     pdeps.append(var)
                     data.setVarFlag(p, 'deps', pdeps, d)
                     bb.build.add_task(p, pdeps, d)
+
+            # now add the handlers
+            if not len(all_handlers) == 0:
+                data.setVar('__all_handlers__', all_handlers, d)
+
         bbpath.pop(0)
     if oldfile:
         bb.data.setVar("FILE", oldfile, d)