-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Ensure MSBuildPanel buttons are instantiated #51322
Conversation
Indeed your current solution is correct (at least as far as we usually do it in Godot's codebase). Weird that I didn't experience the issue, or at least didn't notice it, but this change makes sense. |
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.
As far as I remember, we do initialization on _Ready
because the constructor is always called after hot-reload. If we were to do initialization in the constructor we would be adding extra child buttons every time assemblies were hot-reloaded.
Is it a C# specific thing? Neither C++ side nor GDScript would do that (unless it was terminated improperly). Also, why would it hot reload at all? 🙃 |
I don't know if GDScript calls
Because we need to destroy the domain, start a new one and reload assemblies back. So we need to reload everything if something changes. |
But shouldn't all the UI nodes be removed from the tree and destroyed when you do a complete reload? |
No, they are not removed on reload regardless of the language. |
d0d50ff
to
ca57d00
Compare
That makes sense. I was under the impression the game assembly was the only one that needed to be reloaded.
That would be nice. I have updated the PR to use |
ca57d00
to
f20db58
Compare
if (errorsBtn != null) | ||
errorsBtn.Icon = GetThemeIcon("StatusError", "EditorIcons"); | ||
if (warningsBtn != null) | ||
warningsBtn.Icon = GetThemeIcon("NodeWarning", "EditorIcons"); |
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.
Null conditional operator ?.
would be shorter and more readable. But it's nothing important.
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 can't use it on an assignment: The left-hand side of an assignment must be a variable, property or indexer
.
Thanks! |
After #51220,
MSBuildPanel
was throwing aNullReferenceException
on the_Notification
method since the method can get called before the_Ready
method where the buttons are instantiated so it was trying to set the icon of a null button. This PR initializes the panel in the constructor instead of using the_Ready
method to make sure the buttons are never null.An alternative implementation would be to leave the initialization in the
_Ready
method and check if the buttons are null in the_Notification
method, but it doesn't seem like we need to wait for_Ready
to do any of the initialization thatMSBuildPanel
does so it can be done in the constructor.Bugsquad edit: Fixes #51344.