Skip to content
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

Fix engine crashing when using Down Arrow selection on Tree with no selection #93179

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

TheSofox
Copy link
Contributor

Fixes #92958

Now when Down (or Up) key is used to change selection on a Tree with SELECT_MULTI enabled, the code will check whether anything is selected before trying to change the selection. Previously it would not perform this check and a crash would be possible if nothing was selected.

This has a different approach from #92959, though aiming to solve the same bug.

scene/gui/tree.cpp Outdated Show resolved Hide resolved
scene/gui/tree.cpp Outdated Show resolved Hide resolved
@KoBeWi
Copy link
Member

KoBeWi commented Jun 19, 2024

When nothing is selected, you can't use arrows or any other button to select something. Which means that you can't select any item when you are Tabbing into the tree, making it less friendly for keyboard controls.

#92959 seems like a better approach, but it still has the problem I mentioned in my comment. Code of both PRs looks fine though.

@TheSofox
Copy link
Contributor Author

TheSofox commented Jun 22, 2024

Amended commit to be more like #92959 Seemed to fix the issues @Hilderin raised.
Since the issue was raised on the other PR, I tried to reproduce the "selecting folded nodes" glitch but it seemed to work okay. If anyone reproduces it, let me know with repo steps.

In general, this PR seems to work well.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 22, 2024

If anyone reproduces it, let me know with repo steps.

  1. Have some folded node at the bottom of the scene.
  2. Deselect all nodes.
  3. Save the scene.
  4. Reload the scene.
  5. Click empty space in scene tree.
  6. Press Up.

@TheSofox
Copy link
Contributor Author

Thanks for the repo steps! The problem was get_last_item() didn't take into consideration whether the last item was hidden by a collapsed parent or not. Apparently this function is only used by _go_up(), so I modified it to only choose the last visible item.

scene/gui/tree.cpp Outdated Show resolved Hide resolved
scene/gui/tree.cpp Outdated Show resolved Hide resolved
@akien-mga akien-mga merged commit bf20231 into godotengine:master Jun 24, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Engine crashes clicking the down-arrow after clicking in the File System blank area (no file selected)
5 participants