Godot version:
031b545
Issue description:
When saving a scene, the signal connections from instanced scenes will change positions every now and then in the .tscn file.
Very likely related to #30538.
I've been having this same issue and it's been driving me crazy. I don't want a bunch of useless commits titled "Godot randomly changed signal order for no apparent reason"
Could this be fixed by ensuring signal connections are saved in alphabetical order?
Signals are sorted according to their parent node index in the scene, and they are sorted again in alphabetical order if they are from the same node.
So I think changing the node index can be a cause for it.
I've now noticed that this issue seems to be triggered after modifying scene files and then discarding the changes. After the changes have been discarded, these reordered signals seems to linger for some reason. Unfortunately this still seems to be somewhat random and isn't easily reproducible, but it seems to trigger it in some situations. The only notable files in my gitignore are the .import/ and export/ directories which I think are supposed to be safe to exclude from version control.
Edit: Here's my full gitignore:
.import/
.mono/
.vscode/
export/
export.cfg
export_presets.cfg
Okay, so I've ran into this again and toyed around with things to try and figure out what seems to trigger it. You can disregard my previous comment. It has nothing to do with discarding changes or really any changes at all.
What seems to happen is every time my scene is read from disk, signals in that scene that emit to at least two separate nodes will be randomly ordered among each other. So if I have SignalA that emits to NodeA and NodeB, within the scene's tscn file, the lines(for that signal) for NodeA and NodeB will swap back and forth with each other at random when it is read from disk. I know it happens when it is read from disk because if I commit these lines being reordered, no matter how many times I resave that scene after committing the changes, those lines will not be reordered until I close the scene or the editor and reopen it.
Since it only happens when it is read from disk, it previously appeared as if it happened when I discarded changes, because I would close the project and discard the changes from git, so when I reopened the project after discarding the changes, the scene would be read from disk and the signals would be randomly reordered.
Most helpful comment
Could this be fixed by ensuring signal connections are saved in alphabetical order?