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

Default Project Path editor setting acts incorrectly if it ends in a trailing slash #99689

Open
Calinou opened this issue Nov 25, 2024 · 3 comments · May be fixed by #99776
Open

Default Project Path editor setting acts incorrectly if it ends in a trailing slash #99689

Calinou opened this issue Nov 25, 2024 · 3 comments · May be fixed by #99776

Comments

@Calinou
Copy link
Member

Calinou commented Nov 25, 2024

Tested versions

  • Reproducible in: 4.3.stable

System information

Godot v4.3.stable - Fedora Linux 41 (KDE Plasma) - X11 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4090 (nvidia; 565.57.01) - 13th Gen Intel(R) Core(TM) i9-13900K (32 Threads)

Issue description

The Default Project Path editor setting acts incorrectly if it ends in a trailing slash. This can happen if you manually enter or paste a path from elsewhere, so we should ensure both act identical by stripping the trailing slash when reading the setting if it's there.

Default Project Path = /home/hugo/Documents/Godot

No trailing slash.

Image

Default Project Path = /home/hugo/Documents/Godot/

With trailing slash. Notice how there's one extra folder component which isn't desired here.

Image

Steps to reproduce

  • Set Default Project Path editor setting to a value that ends with a trailing slash. You can do this by manually entering the slash in the path (without using the Browse icon on the right).

Minimal reproduction project (MRP)

N/A

@peterdang1502
Copy link

peterdang1502 commented Nov 26, 2024

I can help look into this if anyone can give me a pointer to where the default project path gets set. After looking through the code in the debugger, I think it has something to do with this block of code on line 586 in the editor_settings.cpp file:

// Directories
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/directories/autoscan_project_path", "", "")
const String fs_dir_default_project_path = OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_GLOBAL_DIR, "filesystem/directories/default_project_path", fs_dir_default_project_path, "")

But when I change the default path, the variable fs_dir_default_project_path just points to my system's default path I think, so I'm unsure of where the default path is getting set after I change it in the editor.

@amarsero
Copy link

Hi @peterdang1502, i think what you are looking for is in EditorSettings::_set#L64.

I was thinking maybe it's better to just clean the path when reading the setting somewhere around ProjectDialog::show_dialog#L760?

@peterdang1502
Copy link

Thank you for the pointer @amarsero !! Putting up PR soon.

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

Successfully merging a pull request may close this issue.

5 participants