Skip to content

Do not grab focus on filename LineEdit in EditorFileDialog when outside the tree#106260

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Rubonnek:fix-pot-dialog-config
May 19, 2025
Merged

Do not grab focus on filename LineEdit in EditorFileDialog when outside the tree#106260
Repiteo merged 1 commit into
godotengine:masterfrom
Rubonnek:fix-pot-dialog-config

Conversation

@Rubonnek
Copy link
Copy Markdown
Member

@Rubonnek Rubonnek commented May 10, 2025

When a POT is generated for the first time, last_pot_path is added to the project metadata and this value gets used the next time the Editor runs to configure the POT generator dialog.

The problem is that currently the code configures the dialog too early and an error shows up the next time the Editor runs:

ERROR: Condition "!is_inside_tree()" is true.
   at: grab_focus (scene/gui/control.cpp:2210)

This PR fixes this issue.

To reproduce the bug, simply run the following project in the CLI:

POTGeneratorDialogBug.zip

@Rubonnek Rubonnek added this to the 4.5 milestone May 10, 2025
Comment thread editor/localization_editor.cpp Outdated
@timothyqiu
Copy link
Copy Markdown
Member

I checked the relevant code and I think the error is caused by the EditorFileDialog instead of the POT generator. Calling set_current_file() when the dialog is not in tree should not try to focus the filename LineEdit.

@Rubonnek Rubonnek force-pushed the fix-pot-dialog-config branch from a7fcbce to 04b4c05 Compare May 17, 2025 17:31
@Rubonnek Rubonnek requested review from a team as code owners May 17, 2025 17:31
@Rubonnek Rubonnek changed the title Configure POT generator dialog when it's ready Do not grab focus on filename LineEdit in EditorFileDialog when outside the tree May 17, 2025
@Rubonnek Rubonnek changed the title Do not grab focus on filename LineEdit in EditorFileDialog when outside the tree Do not grab focus on filename LineEdit in EditorFileDialog when outside the tree May 17, 2025
@Rubonnek
Copy link
Copy Markdown
Member Author

Rubonnek commented May 17, 2025

when the dialog is not in tree should not try to focus the filename LineEdit

Patched EditorFileDialog to match this behavior which is also the current behavior in FileDialog as implemented back in #56457.

The LineEdit focus is still grabbed afterwards when the dialog itself is popped up.

Copy link
Copy Markdown
Member

@timothyqiu timothyqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented May 18, 2025

You can instead move this call into the condition below:

_focus_file_text();
if (is_visible()) {

_focus_file_text() is called on dialog popup, so it's irrelevant when the dialog is hidden.

@Rubonnek Rubonnek force-pushed the fix-pot-dialog-config branch from 04b4c05 to 4138fdb Compare May 18, 2025 16:45
@Rubonnek
Copy link
Copy Markdown
Member Author

You can instead move this call into the condition below

Done.

Comment thread editor/gui/editor_file_dialog.cpp Outdated
@Rubonnek Rubonnek force-pushed the fix-pot-dialog-config branch from 4138fdb to 1dbbb94 Compare May 18, 2025 17:05
@Rubonnek Rubonnek requested a review from a team as a code owner May 18, 2025 17:05
@Rubonnek Rubonnek force-pushed the fix-pot-dialog-config branch from 1dbbb94 to 8bd1b5f Compare May 18, 2025 17:06
@Repiteo Repiteo merged commit a6e80ec into godotengine:master May 19, 2025
20 checks passed
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented May 19, 2025

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.

4 participants