-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signal connections from instanced children change positions in .tscn file #35084
Comments
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. |
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:
|
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 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. |
Is this still reproducible in Godot 3.3 or later? |
I can confirm that it is still reproducible in my case on 3.3 stable. |
I can confirm this is still an issue in 3.3 stable. For signals with the same signal name and source node, Godot orders signals signals arbitrarily and the order often changes. Here is an example of a commit where the Godot editor shuffled several signals in this As a workaround, I've written a shell script which manually sorts the signals in my .tscn files. #!/bin/bash
while read -r IN_FILE
do
echo "Sorting signal connections in $IN_FILE..."
OUT_FILE="$IN_FILE"~
# calculate the range of lines to sort
FIRST_LINE=$(awk '/^\[connection signal/{print NR; exit}' "$IN_FILE")
LINE_COUNT=$(grep -c "^\[connection signal" "$IN_FILE")
# move the 'signal=' attribute after the 'from=' attribute so that the signal sort order mostly matches Godot
sed -i "s/^\\(\\[connection\\)\\( signal=\"[^\"]*\"\\)\\( from=\"[^\"]*\"\\)\\(.*\\)/\\1\\3\\2\\4/g" "$IN_FILE"
# sort the '[connection]' lines
(head -n $(("$FIRST_LINE" - 1)); head -n "$LINE_COUNT" | sort; cat ) < "$IN_FILE" 1<> "$OUT_FILE"
mv -f "$OUT_FILE" "$IN_FILE"
# move the 'signal=' attribute back where it was
sed -i "s/^\\(\\[connection\\)\\( from=\"[^\"]*\"\\)\\( signal=\"[^\"]*\"\\)\\(.*\\)/\\1\\3\\2\\4/g" "$IN_FILE"
done < <(git diff master --name-only | grep "\.tscn$") (I'm rubbish at shell scripting, so I'd be receptive to any script improvements or a simpler workaround.) |
I investigated this issue (on master) and tracked it down as far as Callable comparison. The signals are sorted by name, but if the name is the same, they are sorted by target Callable. Then the Callable is sorted by method name and if the name is the same, they are sorted by target ObjectID. The ObjectID will be different every time, so this is most likely the source of randomness. I assume it's similar in 3.x. EDIT: EDIT2: EDIT3: |
Fixed by #52493 |
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.
The text was updated successfully, but these errors were encountered: