diff options
author | Josh Morman <jmorman@perspectalabs.com> | 2019-07-18 19:09:28 -0400 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2019-07-19 23:42:45 +0200 |
commit | e97c79abff60d752574fbb1b8caae5b9a35b3fc1 (patch) | |
tree | 9d3faaff6fca428881cd10212657d36a8e09996a /grc | |
parent | 0ab6a74caf362f2f95509e4303fc111d24a9cc1b (diff) |
grc: restore copy/paste behavior
Restores the gnuradio 3.7 copy/paste behavior where the variable name is
changed to x_# of the copied block if the name is in conflict. The
issue in 3.8 was that blocks always got copied as variable_# even when
there was no conflict in naming
Fixes #2614
Diffstat (limited to 'grc')
-rw-r--r-- | grc/gui/canvas/flowgraph.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/grc/gui/canvas/flowgraph.py b/grc/gui/canvas/flowgraph.py index a9010026c3..248ea3ba22 100644 --- a/grc/gui/canvas/flowgraph.py +++ b/grc/gui/canvas/flowgraph.py @@ -280,6 +280,13 @@ class FlowGraph(CoreFlowgraph, Drawable): block_key = block_n.get('id') if block_key == 'options': continue + + block_name = block_n.get('name') + # Verify whether a block with this name exists before adding it + if block_name in (blk.name for blk in self.blocks): + block_name = self._get_unique_id(block_name) + block_n['name'] = block_name + block = self.new_block(block_key) if not block: continue # unknown block was pasted (e.g. dummy block) @@ -290,8 +297,7 @@ class FlowGraph(CoreFlowgraph, Drawable): # move block to offset coordinate block.move((x_off, y_off)) - if block.params['id'].value in (blk.name for blk in self.blocks): - block.params['id'].value = self._get_unique_id(block_key) + #TODO: prevent block from being pasted directly on top of another block # update before creating connections self.update() |