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

CreateDefaultSubobject must be called within ctor #264

Open
A-Paterson opened this issue Dec 20, 2019 · 6 comments
Open

CreateDefaultSubobject must be called within ctor #264

A-Paterson opened this issue Dec 20, 2019 · 6 comments

Comments

@A-Paterson
Copy link

@A-Paterson A-Paterson commented Dec 20, 2019

Hi,

I am new to the Unreal engine and Unreal.js. After copying the first person example on the wiki, I got this error:

CreateDefaultSubobject must be called within ctor

This was caused by:

let tempCamera = CameraComponent.CreateDefaultSubobject("FP_Camera")

It is inside the ctor function.

Thanks for any help,
Alex

@thejustinwalsh

This comment has been minimized.

Copy link

@thejustinwalsh thejustinwalsh commented Mar 10, 2020

I am looking at the same code and running into the same error. To me it looks like the code that was calling the ctor in Javascript got moved to // move to javascriptgeneratedclass_* according to some commented out code sitting in JacvascriptContext_private.cpp around line 761. From what I can tell prector() is being called when the ObjectInitializer is valid, and the ctor() function is being called after the object has already initialized. So unless that is a bug try creating your component in prector() instead.

@thejustinwalsh

This comment has been minimized.

Copy link

@thejustinwalsh thejustinwalsh commented Mar 10, 2020

If I restore the code in JavascriptContext_private.cpp and comment out the call of the ctor() in JavascriptGeneratedClass.cpp all of my code that was working in 4.21 is now working in 4.23.

If I move all my CreateDefaultSubobject calls to prector() I get all kinds of fun invalid memory access crashes.

I think we have a bug on our hands, or a new pattern for calling CreateDefaultSubobject, that I do not see documented anywhere.

@thejustinwalsh

This comment has been minimized.

Copy link

@thejustinwalsh thejustinwalsh commented Mar 10, 2020

Looks like this code was changed 6 months ago in a big merge from commit 44dfabd

@A-Paterson

This comment has been minimized.

Copy link
Author

@A-Paterson A-Paterson commented Mar 10, 2020

I tried prector () and it crashed.

@thejustinwalsh

This comment has been minimized.

Copy link

@thejustinwalsh thejustinwalsh commented Mar 10, 2020

I can submit a PR but without any kind of tests I am not sure if it was intended to break this functionality in an attempt to enable something else.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.