-
-
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
Remove non-existing global class from cache #86067
Remove non-existing global class from cache #86067
Conversation
d3248d8
to
33c11e6
Compare
ScriptServer::save_global_classes(); | ||
print_verbose("Removed class " + p_type + " from global classes."); | ||
return; | ||
} |
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.
Not sure if CreateDialog should be responsible for cleaning classes..
String path = OS::get_singleton()->get_resource_dir() + file.replace_first("res://", "/"); | ||
print_verbose("Moving to trash: " + path); | ||
Error err = OS::get_singleton()->move_to_trash(path); |
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.
This is wrong. It makes every file deleted separately when deleting directories.
You should still use files_to_delete
for this action.
} | ||
|
||
EditorFileSystem::get_singleton()->update_file(file); |
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.
Is this always necessary? When you delete directory, this should be handled by rescan (like in the old code).
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.
Then maybe the rescan should be fixed? Currently it doesn't handle delete directories. There is some code to handle deleted directories, but it is never called (at least not when directories are deleted from FileSystem).
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.
Well I was more asking whether this line fixes anything. If there is a case not handled by the above lines then this one could stay.
Superseded by #90186. Thanks for the contribution! |
Fixes problems with deleting script files containing global classes.
Fixes #81867
Test cases
Test project contains two new classes,
my_good_sprite_2d.gd
located in root and another inbad/my_bad_sprite_2d.gd
.g42_cache_test.zip
Open Godot and test project
Start adding new node by clicking + button in Scene tree.
--> SUCCESS: MyBadSprite2D is possible node type, no errors
Delete directory "bad"
Start adding new node by clicking + button in Scene tree.
--> FAIL: You get errors
my_good_sprite_2d.gd
from file system--> FAIL: Now you errors also from MyGoodSprite2D
The only situation where removing classes from cache file works, is when only files, not directories, are deleted in Godot editor.
Fixes
The reason for the errors is that the global classes made by the user are not properly removed from
.godot/global_script_class_cache.cfg
.create_dialog.cpp
fix the situation when files are deleted externally. When a non-existing global class is detected, it is removed from the cache. This prevents further errors.dependency_editor.cpp
fix the situation when a folder containing a class file is deleted in Godot editor. When directories are deleted, master doesn't process each deleted file the same way as single deleted files are processed. Instead it is assumed that EditorFileSystem's scan will handle this, but it doesn't. Scan doesn't notice deleted directories at all. Now for every deleted file, EditorFileSystem'supdate_file
is called and the global class (if file contains one) is deleted from cache file.