From e98dee4f0ec25e3062760f3aeb7642c490e9464a Mon Sep 17 00:00:00 2001
From: Sebastian Koslowski <koslowski@kit.edu>
Date: Fri, 17 Jul 2015 17:41:42 +0200
Subject: grc: clean-up Block port counters

---
 grc/python/Port.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

(limited to 'grc/python/Port.py')

diff --git a/grc/python/Port.py b/grc/python/Port.py
index 765e1d7423..249d7aed71 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -100,14 +100,11 @@ class Port(_Port, _GUIPort):
         elif n['domain'] == GR_MESSAGE_DOMAIN:
             n['key'] = n['name']
             n['type'] = 'message'  # for port color
-        if n['type'] == 'msg': n['key'] = 'msg'
-        if dir == 'source' and not n.find('key'):
-            n['key'] = str(block._source_count)
-            block._source_count += 1
-        if dir == 'sink' and not n.find('key'):
-            n['key'] = str(block._sink_count)
-            block._sink_count += 1
-        #build the port
+        if n['type'] == 'msg':
+            n['key'] = 'msg'
+        if not n.find('key'):
+            n['key'] = str(next(block.port_counters[dir == 'source']))
+        # build the port
         _Port.__init__(
             self,
             block=block,
-- 
cgit v1.2.3