-
-
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
Ensure MainLoop
and its custom script is set right after it's resolved
#70771
Ensure MainLoop
and its custom script is set right after it's resolved
#70771
Conversation
MainLoop
is set right after it's resolved
6de1e07
to
7105cd2
Compare
MainLoop
is set right after it's resolvedMainLoop
and its custom script is set right after it's resolved
7105cd2
to
db48df3
Compare
@@ -2705,6 +2705,8 @@ bool Main::start() { | |||
} | |||
} | |||
|
|||
OS::get_singleton()->set_main_loop(main_loop); |
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.
Why moving this here?
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.
The if
below handling SceneTree
-derived main_loop
adds nodes to the tree (autoloads, main scene), meaning it can trigger some user code. If they'd use Engine.get_main_loop()
in there it would return null
at this point because it was not set yet (pre moving it in here). This fixes e.g. snippet from #70764 (comment).
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.
Isn't it strange that main_loop (base or overriden) becomes initialized after first scene is initialized?
UPD Did some research #71695
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.
Hard to assess all the implications, but GTG IMO post-4.1. If this were not completely right, things would start exploding noticeably.
Thanks! |
For a
SceneTree
-derivedmain_loop
theOS::get_singleton()->set_main_loop(main_loop);
was called after adding AutoLoads and the main scene to the tree. This PR makes it be set right after themain_loop
is resolved.Also previously setting custom script of the
main_loop
was postponed (viaMainLoop::set_initialize_script
) to be done inMainLoop::initialize
. This PR removesMainLoop::set_initialize_script
and makes the script of themain_loop
be set directly right after it's instantiated.Fixes #70764.