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 file name comparison when new file is added to file system #45070

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

fmazan
Copy link
Contributor

@fmazan fmazan commented Jan 10, 2021

Fixes #45027.

It was caused by improper comparison between full file path vs. file name only.

Copy link
Contributor

@KiritoAM KiritoAM 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!
Note that the associated bug is only present if your file list is sorted by name (FILE_SORT_NAME or FILE_SORT_NAME_REVERSE). This is because FileSystemDock::_sort_file_info_list (which is called when the filesystem changes) does not call the relevant sort_custom variant on the file list for these two sorting types; we assume that the list is already sorted by FILE_SORT_NAME when it enters the function; which it wasn't in this case (with this fix, it now is). Not sure if the same issue is occurring elsewhere due to this assumption.
This does mean that the better fix may be to call sort_custom under these two sorting methods; but personally I'm happy with this fix for this particular issue.

@fmazan
Copy link
Contributor Author

fmazan commented Jan 10, 2021

Looks good to me!
Note that the associated bug is only present if your file list is sorted by name (FILE_SORT_NAME or FILE_SORT_NAME_REVERSE). This is because FileSystemDock::_sort_file_info_list (which is called when the filesystem changes) does not call the relevant sort_custom variant on the file list for these two sorting types; we assume that the list is already sorted by FILE_SORT_NAME when it enters the function; which it wasn't in this case (with this fix, it now is). Not sure if the same issue is occurring elsewhere due to this assumption.
This does mean that the better fix may be to call sort_custom under these two sorting methods; but personally I'm happy with this fix for this particular issue.

Indeed, my first local fix was to force sorting in case of FILE_SORT_NAME and FILE_SORT_NAME_REVERSE, but that was curing symptom rather than the cause. I have looked around the code, and it seemed to me that the files vector was purposely kept sorted by name at all times.

@Calinou Calinou added bug cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:editor labels Jan 10, 2021
@Calinou Calinou added this to the 4.0 milestone Jan 10, 2021
@akien-mga akien-mga requested a review from groud January 11, 2021 11:20
@akien-mga akien-mga merged commit 2af5723 into godotengine:master Jan 14, 2021
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.2.4.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jan 15, 2021
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.

New scripts and resources are not sorted in the file system browser
5 participants