[go: up one dir, main page]

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

[Windows] Fix root and current folder in native file dialog. #99652

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruvzg
Copy link
Member
@bruvzg bruvzg commented Nov 24, 2024

Supersede #98839

Fixes #98832
Fixes #99598

@@ -174,6 +176,7 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
file->set_text(f);
dir->set_text(f.get_base_dir());
filter->select(p_filter);
update_dir();
Copy link
Contributor
@RedMser RedMser Nov 25, 2024

Choose a reason for hiding this comment

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

Suggested change
update_dir();
_change_dir(f.get_base_dir());

current_dir would just be reset to the same value when using update_dir(). Calling _change_dir() properly updates the current_dir and also calls update_dir().

But this made me discover some more bugs:

  1. When listening to the *_selected signals in GDScript, reading current_* variables in the signal handlers gives outdated values, since the values are updated too late. User must wait 1 frame to get updated values. Fix: move the code that updates file and dir above the signal emission.
  2. Reading the value of current_dir (after fixing bug 1) does not include the drive letter. Fix: getter should return full_dir instead I assume?
  3. Reading the value of current_path (after fixing bug 1) returns this: /Users/Public/Test/C:/Users/Public/Test/test123.json. Didn't read the code to figure out why.

Let me know which of these you'd fix in this PR, and I can make issues for the rest!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, probably moving it will work fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried moving it and it works as expected.
Not sure if you saw but I updated my above comment since I found 2 more semi-related bugs, regarding the values of current_dir and current_path after selecting a file/dir in dialog.

Copy link
Contributor
@RedMser RedMser Nov 25, 2024

Choose a reason for hiding this comment

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

I fixed it like this, feel free to cherry-pick: RedMser@bf1d24b (The EditorFileDialog changes are untested!!)

This also fixes embedded file dialogs, which used to return paths like /Users/Public/... for current_dir and current_path, now also returning the drive letter as expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what changing dir_access->get_current_dir() to full_path should do, it should always be the same value.

Copy link
Contributor
@RedMser RedMser Nov 25, 2024

Choose a reason for hiding this comment

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

Yes I guess the EditorFileDialog change is not strictly needed then.

But FileDialog uses dir->get_text(); for get_current_dir() which excludes drive letter.

Or could we even get rid of full_dir variable completely and just use FileDialog::get_current_dir() which would return dir_access->get_current_dir()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I guess the EditorFileDialog change is not strictly needed then.

Missed that it is different in FileDialog (why do we have two almost identical dialogs?), this make sense for the FileDialog. Updated PR.

@bruvzg bruvzg force-pushed the fd_cd_win branch 2 times, most recently from 678d356 to adba8b1 Compare November 25, 2024 12:50
Co-authored-by: RedMser <redmser.jj2@gmail.com>
Copy link
Contributor
@RedMser RedMser left a comment

Choose a reason for hiding this comment

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

Looks good to me. I can't say anything about the root folder fix.

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