-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Memory issue when using cpp operate node , need help #102702
Comments
This is for reporting bugs, this sounds like a support question, please ask in the other community channels for support questions |
I ask for help because I am not sure is these 5 line code incorrect, or Godot code has memory issue. |
Try using the appropriate memory management for your types, it should be |
I tested, Ref not the problem, Ref class has a constructor to accept raw pointer. I really don't understand why just 5 simple line code cause crash..
this works well in GDScript, so anyone can explain me why it not work in cpp? |
Did you try: MeshInstance3D *m_mesh =memnew(MeshInstance3D);
Ref<BoxMesh> m_box_mesh = memnew(BoxMesh);
root->add_child(m_mesh);
m_mesh->set_position(Vector3(2, 0, 0));
m_mesh->set_mesh(m_box_mesh); But please ask in the other community channels to make sure this is a bug and not user error, and if it is a bug please provide an example project for testing |
Just posting a link to this thread in the discord isn't exactly in the spirit of asking for help... Without seeing the full source I can only guess, and my guess is that your class ArchlordNode has been put there without any understanding of the engine architecture - SceneTree::initialize is not where your own init should be injected. Follow this guide for adding internal custom c++ |
Tested versions
4.2.2 stable
System information
Win10 , VS2022
Issue description
I want to port a cpp code using godot, so I will not use gdscript or gdextension. From Doc, gdextension can define new node ,then still need gdscript to operate it , add/remove;.
I added simple code to display a cube,
This is ok, but the strange thing is, If I move these 5 line code to another file, I got memory issue.
Then I enabled the Address Sanitizer,
Can some one told me what's the reason?
Steps to reproduce
add these 5 line code to display a cube,
if inside void SceneTree::initialize() , everything is ok, cube will be displayed;
if outside void SceneTree::initialize() , I put it in a custom class , xxxx::init , it crashed
Minimal reproduction project (MRP)
any empty project
The text was updated successfully, but these errors were encountered: