From 41095980ca9b9562b0c0b354b5a56404b91fe837 Mon Sep 17 00:00:00 2001
From: Josh Morman <jmorman@perspectalabs.com>
Date: Tue, 8 Oct 2019 09:24:32 -0400
Subject: grc: update namespace properly for nested variables

Was getting lots of evaluation error prints when using gr-digital
examples because the nested variables were not updated until rewrite()
and evaluate were called over and over

Seems to fix the issue to update the flowgraph namespace variable after
each variable block is evaluated

I believe this also alleviates a previous issue (#2634) where rewrite
had to be called twice when data was being imported

Fixes #2634
---
 grc/core/FlowGraph.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'grc/core/FlowGraph.py')

diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 6c549a46a2..aff5f48bc7 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -226,6 +226,7 @@ class FlowGraph(Element):
                 variable_block.rewrite()
                 value = eval(variable_block.value, namespace, variable_block.namespace)
                 namespace[variable_block.name] = value
+                self.namespace.update(namespace) # rewrite on subsequent blocks depends on an updated self.namespace 
             except TypeError: #Type Errors may happen, but that desn't matter as they are displayed in the gui
                 pass
             except Exception:
@@ -381,8 +382,7 @@ class FlowGraph(Element):
 
             block.import_data(**block_data)
 
-        self.rewrite()  # TODO: Figure out why this has to be called twice to populate bus ports correctly
-        self.rewrite()  # evaluate stuff like nports before adding connections
+        self.rewrite() 
 
         # build the connections
         def verify_and_get_port(key, block, dir):
-- 
cgit v1.2.3