Skip to content
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

Update deferred calls to use Callables #86301

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Dec 18, 2023

Somewhat follow-up to #67730

This PR changes call_deferred() calls to use Callables, removing many unnecessary method binds as a result. I also changed some usages of MessageQueue to use Callables too.

There is still some usage of old call_deferred() left, namely when a method is vararg or private. I also left some MessageQueue calls in SceneTree, as I'm not sure about performance requirements in there.

EDIT:
btw this might fix some bugs, as there were some methods called that weren't bound, resulting in silent fail.

@YuriSizov
Copy link
Contributor

Ah brilliant, I wanted to do this for so long :) You have an extra empty line, it seems, which fails static checks.

@YuriSizov YuriSizov removed request for a team December 18, 2023 15:02
Comment on lines +283 to +284
callable_mp((Control *)this, &Control::update_minimum_size).call_deferred();
callable_mp((Control *)get_line_edit(), &Control::update_minimum_size).call_deferred();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already called automatically when NOTIFICATION_THEME_CHANGED is received, the only difference is that here it's deferred for both nodes. I wonder if it could be removed.

@KoBeWi KoBeWi force-pushed the deferred_cleanup branch 2 times, most recently from 45f9a15 to 768c0e5 Compare December 18, 2023 16:56
@KoBeWi KoBeWi force-pushed the deferred_cleanup branch 2 times, most recently from 520dcd8 to d61bb4e Compare December 18, 2023 22:26
@@ -37,7 +37,7 @@
#include "core/object/script_language.h"

void Callable::call_deferredp(const Variant **p_arguments, int p_argcount) const {
MessageQueue::get_singleton()->push_callablep(*this, p_arguments, p_argcount);
MessageQueue::get_singleton()->push_callablep(*this, p_arguments, p_argcount, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the deferred calls print error when they fail, instead of doing so silently.

Using callable_mp() can be very error prone, so this helps finding wrong calls. I just wonder if it has unforeseen side effects.

@kitbdev

This comment was marked as resolved.

editor/code_editor.cpp Outdated Show resolved Hide resolved
editor/code_editor.cpp Outdated Show resolved Hide resolved
editor/code_editor.cpp Outdated Show resolved Hide resolved
editor/code_editor.cpp Outdated Show resolved Hide resolved
editor/code_editor.cpp Outdated Show resolved Hide resolved
@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 3, 2024

I triple-checked everything, but still missed some cases. Thanks for looking into it.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't review in depth, but makes sense to me overall. Could be good to merge after 4.3-dev2 is released, giving us some time to spot potential regressions before dev3.

btw this might fix some bugs, as there were some methods called that weren't bound, resulting in silent fail.

This could actually introduce bugs, if the silent failures are now code that's not supposed to be working, and it working would introduce unwanted changes. So these might be worth flagging for relevant maintainers to look at more closely.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 9, 2024

This could actually introduce bugs, if the silent failures are now code that's not supposed to be working, and it working would introduce unwanted changes. So these might be worth flagging for relevant maintainers to look at more closely.

Well, one was in RichTextLabel, I don't remember the other one.

@akien-mga
Copy link
Member

This could actually introduce bugs, if the silent failures are now code that's not supposed to be working, and it working would introduce unwanted changes. So these might be worth flagging for relevant maintainers to look at more closely.

Well, one was in RichTextLabel, I don't remember the other one.

I see one with _emit_navigation_debug_changed_signal in NavigationServer3D, CC @smix8.

@akien-mga akien-mga merged commit 087a397 into godotengine:master Jan 11, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants