Skip to content

Commit

Permalink
[processing] Fix modeler draws lines to wrong output when connecting
Browse files Browse the repository at this point in the history
the green output boxes back to their linked algorithms
  • Loading branch information
nyalldawson committed Jan 31, 2020
1 parent 17448b1 commit 5ae9807
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/plugins/processing/modeler/ModelerScene.py
Expand Up @@ -161,14 +161,23 @@ def paintModel(self, model, controls=True):
for alg in list(model.childAlgorithms().values()):
outputs = alg.modelOutputs()
outputItems = {}
idx = 0

for key, out in outputs.items():
if out is not None:
item = ModelerGraphicItem(out, model, controls, scene=self)
item.setFlag(QGraphicsItem.ItemIsMovable, True)
item.setFlag(QGraphicsItem.ItemIsSelectable, True)
self.addItem(item)
pos = out.position()

# find the actual index of the linked output from the child algorithm it comes from
source_child_alg_outputs = alg.algorithm().outputDefinitions()
idx = -1
for i, child_alg_output in enumerate(source_child_alg_outputs):
if child_alg_output.name() == out.childOutputName():
idx = i
break

if pos is None:
pos = (alg.position() + QPointF(ModelerGraphicItem.BOX_WIDTH, 0) +
self.algItems[alg.childId()].getLinkPointForOutput(idx))
Expand All @@ -180,7 +189,6 @@ def paintModel(self, model, controls=True):
item.addArrow(arrow)
arrow.updatePath()
self.addItem(arrow)
idx += 1
else:
outputItems[key] = None
self.outputItems[alg.childId()] = outputItems
Expand Down

0 comments on commit 5ae9807

Please sign in to comment.