paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework
BSD 3-Clause "New" or "Revised" License
3.03k stars 814 forks source link

[v3alpha] An issue with the working of draft connection #318

Closed velorom closed 2 years ago

velorom commented 2 years ago

In ConnectionGraphicsObject on mouseMove event you transfer self to hovered node for reaction: ngo->reactToConnection(this); This connection is using in NodePainter::drawConnectionPoints for painting ports. And you reset this pointer at the end of this method. But sometimes mouseRelease event of ConnectionGraphicsObject and corresponding destroying of draft connection happens before NodePainter::drawConnectionPoints call. So sometimes NodePainter accesses the destroyed pointer.

I think you need to let the scene set reaction connection to nodes and tracks for it destruction.

paceholder commented 2 years ago

Thanks for pointing this out, I'll have a look in the nearest days.

velorom commented 2 years ago

There is another small fix. Maybe it is a typo, but in NodeGraphicsObject::itemChange you must change the ItemPositionChange value to ItemPositionHasChanged, because you call moveConnections(), where you update connections positions. But at this moment node position is not changed yet. This leads to the effect of connections lagging behind node ports.

paceholder commented 2 years ago
  1. I used QPointer, it is cleared automatically when the object inside is destroyed.
  2. To me the two options were not clearly distinguishable. ItemPositionChange, ItemPositionHasChanged. Now I see the difference.

Thanks for your valuable and inspective remarks!