Fix crash when rearranging filtered animation tracks#111427
Fix crash when rearranging filtered animation tracks#111427Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
TokageItLab
left a comment
There was a problem hiding this comment.
It is good that you identified the cause.
However, having two retrievable values to manage should be avoided from a maintainability perspective. So I believe the issue should be resolved by changing the update timing or adding resetting the state.
I'm with you that having two retrievable indices could get confusing. I don't think I understand what you mean with your alternatives though, can you elaborate a little? In the end there are two different vectors involved ( I could probably also drop |
So in other words, I assume you can remove the focus immediately before filtering. |
Mmm, do you just mean you'd prefer it like fa81a0a (temp commit for discussion purposes)? I feel like you have something more different in mind 😅 |
|
I think that's a similar way. So if there's something that keeps fetching the index, I believe the simplest approach to solve the issue is to abort that fetching by initialize the state. |
|
Okay. So the actual error locations before were
As seen in the last commit, it's easy enough to get rid of the need to fetch the selected |
|
I assume you just need to process sequence to remove all filtering in TrackEditor, perform the sort, and then reapply the filtering. If maintaining an index for sorting is necessary, creating a temporary local array within the function should be fine. The main thing to consider here is that the state of the filtered list after sorting and then removing the filter is undefined. For example, if changes like the following occur, the final result could be one of several possibilities: User's operation: then
If we want consistent results, I think you can ensure that filtered items always appear at the top like Actual behavior on sort filtered |
|
Currently it's actually dependent on where exactly you drop the dragged track. It's always placed next to the track you drop it onto, either directly before or after it depending on which half it's dropped at: Skarminspelning.2025-11-10.215044.mp4I believe this is working about as well as it can, so I don't think this behaviour should change. It's not really affected by this bug, since even before this PR the operation of rearranging the animation tracks itself was always dealing only with unfiltered indices (and then it got things mixed up when trying to manage the UI focus). |
|
Yeah, that should be fine for the reordering.
|
fa81a0a to
e406219
Compare
|
Cleaned up, squashed and rebased. Thanks for the review, diff is a bit smaller now. |
|
Thanks! |
|
Cherry-picked for 4.5.2. |
Fixes #99713.
The root cause was using the real track index (unaffected by filtering) to index into a list of track edit controls (potentially smaller when filtered). Curiously, other than the crash when dropping a track at the bottom the correct control still somehow received focus. This is because there was another opposite index mixup cancelling it out:
_update_tracks()fetched the index of the selected edit control but treated it as a real track index.I found at least one other edge case bug fixed by this PR, that I found no open issue for: Pasting a key via the Edit menu with a track selected and node filtering enabled would paste the key into the wrong track.
For convenience, pre-packaged MRP (original issue provided it as a .tscn code block):
animation-player-crash_2025-10-08_21-27-00.zip