-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
C#: Fix NOTIFICATION_PREDELETE
does not trigger ExitTree
#83262
Conversation
NOTIFICATION_PREDELETE
does not trigger ExitTree
NOTIFICATION_PREDELETE
does not trigger ExitTree
Despite the title this is a core change which can have significant implication for all languages, not just C#. What's the problem with C# specifically that wouldn't affect GDScript or GDExtension? Or is there a more generalized problem? |
In C#, |
I tested again, #78634 sorting in GDE is broken. |
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 PR reverts parts of #78634 and when this PR gets merged in its current form, the following issues need to be reopened, because they will be reintroduced:
Object::notification()
doesn't fully respect itsp_reversed
parameter #52325- Include extensions in the call ordering of notifications godot-proposals#5585
An alternative approach (and my suggestion) would be to investigate in which steps the attached C# script gets forgotten and make necessary adjustments there, so that the scripts are still remembered, when they get called.
ba431be
to
c1d53c9
Compare
@Sauermann @akien-mga |
c1d53c9
to
df68139
Compare
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 looks incorrect. Now it won't call Dispose
when the notification call is reversed, at least until we receive notification 11
(which is NOTIFICATION_EXIT_TREE
but we shouldn't be using an integer literal). However, this notification is only sent for Nodes, so that means Resources and RefCounteds won't be disposed now.
I don't think I understand issue #82279. Does it mean that NOTIFICATION_PREDELETE
is being sent before NOTIFICATION_EXIT_TREE
? That doesn't make sense to me, shouldn't the predelete notification be always the last one? The documentation says it can be used as a "destructor", so we should be able to dispose the C# object when receiving it.
Also, the issues mentioned by @bitsawer seem to affect GDScript as well, so maybe the issue is not exclusive to C# and then it should be fixed in Core for all languages.
return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error); Here the code shows that the The code comments also make it clear that |
df68139
to
e76ac05
Compare
} | ||
|
||
return; | ||
} else if (predelete_notified && p_reversed) { |
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.
After testing, it is not necessary to evaluate p_notification
here.
So I've looked a bit more into this, and this is what I've gathered.
Since I can imagine this being a problem. For example, if Node2D had some state that it clears when receiving In the case of CSharpInstance, this means it will dispose the script before Node has a chance to send The current PR implementation is not good because it relies on receiving another notification after Maybe we could not dispose at all when receiving Alternatively, we could change We could also add a new notification that is sent by |
The inability to trigger |
e76ac05
to
403d5c0
Compare
403d5c0
to
3512c25
Compare
@@ -2003,6 +2003,17 @@ void CSharpInstance::notification(int p_notification, bool p_reversed) { | |||
|
|||
_call_notification(p_notification, p_reversed); | |||
|
|||
if (p_reversed && script_is_node) { |
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.
I think the solution of #83670 is good, but I still updated this PR, added a script_is_node
variable, just as an extra reference for everyone.
Fix #82279
It tests okay on Windows, and it tests using the program from #78634 and
Godot.exe --test
pass.