-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Update filesystem dock on script, scene, and resource creation #52189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like saving any file resource any time will now trigger _rescan()
. It sometimes causes the filesystem dock to hang for a couple of seconds with the "Scanning" message, which is undesired when happening so often. Rescan should be limited only to cases where filesystem actually changes, i.e. there is new file or file was renamed, otherwise it's useless. Maybe as a solution you could temporarily connect the resource_saved
signal as oneshot when New Resource dialog opens and disconnect if it's cancelled.
Also for whatever reason the editor will hang infinitely upon exit and spam this error:
ERROR: Disconnecting nonexistent signal 'resource_saved', callable: FileSystemDock::_rescan.
at: (core\object\object.cpp:1406)
This won't work for scenes. Scenes can be saved at any point in future, and we don't actually have a reference to the scene's resource. And the file path can also change for reasons outside of the editor UI interaction. I guess, we can debounce the rescan. How does that sound? |
It's not a matter of debouncing. If you are working on one scene for e.g. 30 minutes and you save every minute or so (including by running the game), even with debouncing the rescan would be triggered many times without any need.
Yeah scenes are a weird case. We could either check if file exists upon saving scene and if not, trigger rescan. Or give the "New Scene" dialog the deserved makeover, because the fact that it doesn't create the scene was complained about in the past. Personally I don't mind the current behavior, so I'd go with the first option. The second one is out of scope of this PR, so we could also leave the scenes for later I guess. |
ca7a5dc
to
af717a0
Compare
Okay, I've added a new As for the disconnect issue, it seems to be some weird case with |
Seems like it's still possible to create fake folder using scenes. The reason is that the scene tab will remember the path you created the scene with. If file didn't exist when saving, the filesystem will rescan. However it exists on subsequent saves, which creates the folder and doesn't rescan. This can be fixed by updating the scene path in EditorData when the file is created. |
It seems that these issues with saving scenes boil down to much bigger issues within the file handling code, specifically on Windows where the file system is case-insensitive by default. There is also a troubling "feature" that allows users to enter directory names into the It doesn't seem possible to solve these problems in this PR without reliance on tricks and hacks, or making changes to I'll file separate reports on the aforementioned issues so we can look for a better, proper solution to those. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'd leave it like this. The scene issue needs to be specifically triggered, it won't happen to regular users. #famouslastwords
I'd update the commit message though. It no longer updates on saving, only on creation. |
Co-authored-by: Dualtagh Murray <[email protected]>
af717a0
to
e53a579
Compare
Done. Also rebased for the heck of it. And reported those two other problems in the meantime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me but I am not very familiar to the impact this might have, as I am not familiar with how the editor handles files internally (I only worked on the UI part). It likely needs a review from reduz to be sure.
@@ -1130,6 +1131,10 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St | |||
} | |||
|
|||
String path = ProjectSettings::get_singleton()->localize_path(p_path); | |||
DirAccess *da = DirAccess::open("res://"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably protect the remaining of the function from crash with ERR_FAIL_COND(!da)
.
@@ -1673,6 +1682,10 @@ void EditorNode::_save_scene(String p_file, int idx) { | |||
} | |||
flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; | |||
|
|||
DirAccess *da = DirAccess::open("res://"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
After a discussion with reduz it was determined that the initial approach of this PR was excessive. The problem is close to what I've described in #52231. It seems that the check I've mentioned there only tests the name of the file, not the entire path, so that needs to be fixed so that we properly report the issue to the user. We also need to expose a method to validate/sanitize the path against the file system, so that This method can be exposed on So this is what needs to be done to properly fix this. @mhilbrunner if you still want to work on #52231, I think we should probably do it together to close both issues at the same time. |
Supersedes #22686.
Fixes #22475 among other related issues. With this change the filesystem dock correctly updates on script creation, as well as any resource saving (so that we support resources and scenes, as mentioned by @KoBeWi). Unfortunately, proposed additions to
_make_scene_confirm()
and_resource_created()
wouldn't work, as scenes and resources are saved after these calls. So I've moved to signals. Scenes don't have any that I can see, so I've reused the one for resources (after all,PackedScene
is a resource, so it should be ok).Note that when a folder is created, the whole dock shows a progress bar, but this is not the case for these new rescans. Not sure what's the problem here, as that code is supposed to be triggered by
_rescan()
. Either way this only results in the file list displaying the old order for a second and then quickly updating to display the correct names and order.Also note, that this is unlikely Windows-specific (the initial issue with casing is, but not the entire situation).
@KoBeWi feel free to merge if you approve, consider me implementing the suggested changes as my own approval as well 🙂