godotengine / godotengine/godot-cpp

'this' always returns nullptr in member functions called from another class instance.

Open
#315 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

Whenever a class/script instance tries to invoke a member function belonging to another class instance, the implicit 'this' pointer always returns nullptr like if the method was run as a static function.

As a result of this, whenever a class attribute is referenced in the invoked member function, a read access violation exception is thrown, crashing the game.

Example:
```
void FooNode::_process(float delta)
{
// thing is a reference to a ThingNode2D node instance.
thing->do_stuff();
}

void ThingNode2D::do_stuff()
{
attribute = 5;
}
```
This crashes when the member variable 'attribute' is read.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.