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

Let thread func have optional parameter #38078

Merged
merged 1 commit into from
Jul 13, 2021
Merged

Conversation

Faymoon
Copy link

@Faymoon Faymoon commented Apr 21, 2020

Fixes #38042

@YeldhamDev YeldhamDev added this to the 4.0 milestone Apr 21, 2020
@YeldhamDev YeldhamDev added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Apr 21, 2020
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Looks good to me, but this should be tested on the latest master and 3.x branches before it can be merged (with the multi-threading modernization in place).

@akien-mga akien-mga requested a review from RandomShaper July 6, 2021 10:23
@@ -2098,10 +2098,11 @@ void _Thread::_start_func(void *ud) {
memdelete(tud);
Callable::CallError ce;
const Variant *arg[1] = { &t->userdata };
int argc = arg[0]->get_type() != 0;
Copy link
Member

Choose a reason for hiding this comment

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

This should use Variant::NIL, not 0.

And I'd make the cast from bool to int explicit:

Suggested change
int argc = arg[0]->get_type() != 0;
int argc = (int)(arg[0]->get_type() != Variant::NIL);

@akien-mga
Copy link
Member

Sorry for the late review.

This would need a rebase for the master branch (core/bind/core_bind.cpp moved to core/core_bind.cpp) but otherwise the code is still the same so this fix might still be relevant.

The fix looks OK to me but I'll let @RandomShaper or @reduz validate as they know this code better.

FYI, the email used to author your commit (see https://patch-diff.githubusercontent.com/raw/godotengine/godot/pull/38078.patch) is not affiliated to your GitHub account. It's not a problem for Git, but if you want to claim ownership of that commit, you can add this email as secondary email in your GH settings.

@Faymoon Faymoon requested a review from a team as a code owner July 13, 2021 08:45
@akien-mga
Copy link
Member

akien-mga commented Jul 13, 2021

Force pushed a rebase that solves merge conflict and my above comment.

@akien-mga akien-mga merged commit c7d13f0 into godotengine:master Jul 13, 2021
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@akien-mga
Copy link
Member

Cherry-picked for 3.4.

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.

Threads dont work with optional arguments
5 participants