godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.88k stars 20.15k forks source link

`GraphEdit` emits `scroll_offset_changed` signal in cases where scroll_offset hasn't changed #76270

Open ParanoidHawk opened 1 year ago

ParanoidHawk commented 1 year ago

Godot version

4.0.2.stable

System information

Windows 10

Issue description

When using GraphEdit, the scroll_offset_changed signal will emit under circumstances where you wouldn't expect/it shouldn't be emitting, where the scroll_offset has not actually changed.

Noticeably this happens when adding a new GraphNode child, as well as if you just click on the graph without moving it at all.

Steps to reproduce

Using the reproduction project attached, go into the Offset Demo plugin screen at the top next to AssetLib. Open the output window to see messages for when the scroll_offset is changed.

Add a node to the graph using the 'Add node' button and see the scroll offset signal occurring, without the offset ever changing. Clicking on the graph will also cause the behaviour.

(The repro project was edited in the 4.1 development branch to check it still existed but this behaviour was first observed on 4.0.2.stable.)

Minimal reproduction project

scroll offset minrepro.zip

ParanoidHawk commented 1 year ago

Found that this bug occurs because the scroll_offset_changed signal is emitted in _update_scroll_offset, which is called every time the graph is redrawn for any reason whatsoever.

This seems to be an issue introduced by the fix for #72479.

ParanoidHawk commented 1 year ago

Made a PR at #76322, need some guidance on whether how I've implemented the fix is within the project's guidelines, and whether what I've deleted has effects on other types of graphs in the editor I'm not aware of that people more familiar will be able to point out.