-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
NOTIFICATION_TRANSLATION_CHANGED
gets sent at wrong times
#89804
Comments
This is by design, and it matters, the translation isn't known until it enters the tree so having this emitted is necessary, how else would you know what the configured translation for the tree is? This should maybe be documented better though The main issue here is simply that you aren't adjusting to how the engine works
The node isn't ready until its children are, they have already had
The solution to that is to just do those on the translation notification though, right? Edit: The issue here (which isn't clear from the description) seems to be that it's fired on entering the tree, not in We could theoretically move it to some other point in the initialization, but that's a complex question, and depends on various use cases |
Using the translation notification instead of In my opinion the notification should only be sent when setting the locale, not when node enters tree. That would be how it worked before 4.3.dev4. |
How would you know? What if it's configured for a different locale than the current one?
Well that's your opinion, and it's different from the people developing this feature :) |
Well, as i am the one who wrote the code of the MRP , i know it will never change the translation, nor does it even have any translations in the project.
Uhhh |
So you don't care about this notification... So your use case isn't relevant, why are you even using the notification if you're not using translation? Bur you're missing my point: |
No i just made a MRP. I discovered the problem in GodSVG when opening in 4.3 dev. It will currently crash due to this when you click on the settings button. This doesn't happen in 4.2 or 4.3.dev3.
It just entered the tree and used the currently set locale to translate everything. The notification is generally only used to update nodes when they are already in the tree. |
That's inefficient though, why not just use the single notification, that's much more efficient, you're only considering this an issue because you're used to one method, it makes a lot of sense and improves a lot of code, avoids duplication of code, etc. You really don't see the value of this? But as I said already, you need to adjust your code to how the engine works, that's what happens with compatibility breakage :) so the crash isn't a bug with this, it's because your code isn't fixed to adjust to how the engine works, please try updating your code so it works |
I don't understand how that's supposed to happen more efficiently. How would the code of the MRP need to change? I can only see this working by adding an is_node_ready(). |
To adjust to translation specially, handle it in a safe way, I don't see why you change the translation of another node, it should do that itself? It should not rely on As I already said we can evaluate and discuss if this should be moved after Note that in 4.2 you'd still error if you, for example, called |
Note however that these notifications are mostly used internally, where nodes are created from code instead of being part of an instantiated scene. Hence there is discrepancy between core usage and how would users typically use it. You should use these notifications only on the current nodes, nodes created from script inside We should document this if it isn't mentioned already. EDIT: |
Tested versions
Likely due to #87530 (@YeldhamDev)
System information
Windows 10
Issue description
The notification
NOTIFICATION_TRANSLATION_CHANGED
now gets emit whencreating nodesnodes enter the tree.It happens before the node is ready, which leads to crashes in one of the most common use case: you hook something like
update_ui()
to it. Generally the function to update UI will set a bunch of text on other nodes, but as the node just got created and its children aren't ready, it will lead to crashes. This also creates duplicate calls to theupdate_ui
, because in most uses_ready
would already take care of initial setup call.Steps to reproduce
_notification
forNOTIFICATION_TRANSLATION_CHANGED
. (print something or put a breakpoint)Minimal reproduction project (MRP)
Translation changed bug MRP.zip
The text was updated successfully, but these errors were encountered: