-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Using "Save As" in script editor crashes with DEV_ENABLED
(reference count below zero)
#74069
Comments
So, I'm not entirely sure how the ref count gets to zero, because it's impossible to place breakpoints this low level. But what I understand about what's happening is all sorts of problematic (though not necessarily related to the crash).
The reason why the counter is going below zero is not clear to me, and maybe it's because of the combination of the steps described, but maybe not. In either case, there seems to be a bigger problem at hand, with saving, loading, and updating resources in memory. While GDScript specifically crashes (other resources I've tried do not), it's not an issue that has to be solved on GDScript's side, IMO. In addition, I have another suspicion about an erroneous behavior related to this process. The editor assumes that when it saves a resource, the currently loaded copy is going to be associated with the new path (which doesn't happen, but the editor expects it to happen). Even if it worked correctly, this logic doesn't seem to handle UIDs in any way. According to KoBeWi, when we save a resource at a new path, a new UID is supposed to be generated. But the UID for the resource in memory is never changed. So successfully updating the path would not be enough for most resources (except for scripts, which don't have UIDs), and UIDs also need to be updated. Not entirely sure what the solution is here, and I'll try to think of one, but here's my findings anyway. |
So I made a PR that partially addresses the issues I've identified. It makes sure that the editor does not update its information about resources too early, and thus prevents weird duplication from incorrect loading. And it seems to solve the crash. |
Godot version
4.0.rc (8208060)
System information
Arch Linux
Issue description
Using the
Save As...
function in the script editor crashes withDEV_ENABLED
builds because the reference count of the script goes below zero.Steps to reproduce
File
>Save As...
.Save
.Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: