diff options
author | Sebastian Koslowski <sebastian.koslowski@gmail.com> | 2018-04-04 23:27:28 +0200 |
---|---|---|
committer | Marcus Müller <marcus.mueller@ettus.com> | 2018-04-28 15:42:41 +0200 |
commit | 89f279aad64681b38a9b5fa8099c8e121cc7861d (patch) | |
tree | a1f65b46b0c15b928436d76b666f69c0f900e2b3 | |
parent | aa54d6b781f7dbfda7fa7948aa60ea03dbd49602 (diff) |
grc: fix grid_pos eval
-rw-r--r-- | grc/core/Param.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/grc/core/Param.py b/grc/core/Param.py index f54a16ed9f..7565703a6b 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -552,6 +552,7 @@ class Param(Element): # Grid Position Type ######################### elif t == 'grid_pos': + self.hostage_cells.clear() if not v: # Allow for empty grid pos return '' @@ -571,15 +572,18 @@ class Param(Element): except: my_parent = '' # Calculate hostage cells - for r in range(row_span): - for c in range(col_span): - self.hostage_cells.append((my_parent, (row + r, col + c))) - # Avoid collisions - params = filter(lambda p: p is not self, self.get_all_params('grid_pos')) - for param in params: - for parent, cell in param._hostage_cells: - if (parent, cell) in self.hostage_cells: - raise Exception('Another graphical element is using parent "{0}", cell "{1}".'.format(str(parent), str(cell))) + for r in range(row, row + row_span): + for c in range(col, col + col_span): + self.hostage_cells.add((my_parent, (r, c))) + + for other in self.get_all_params('grid_pos'): + if other is self: + continue + collision = next(iter(self.hostage_cells & other.hostage_cells), None) + if collision: + raise Exception('Block {block!r} is also using parent {parent!r}, cell {cell!r}.'.format( + block=other.get_parent().get_id(), parent=collision[0] or 'main', cell=collision[1] + )) return e ######################### # Notebook Page Type |