Jump to content

[SOLVED] Using class instances related to the component system.


photo

Recommended Posts

Posted (edited)

An error occurs when obtaining a node pointer.

Nodeptr continues to be expressed as null.

image.png.f42f2114e16b8a5f226f8d331a347548.png

image.png.781a9cf7938cc7f5b5624fbdf765910a.png

However, even if it is expressed as null, Nodeptr is used normally. (Do not cause a pointer error)

 

The same phenomenon occurs when a pointer of another class is obtained as getcomponent<C>() method.

in this instance,
An instance of another class is expressed as nullptr, but the function of the class is used normally, and the variable does not change even if a input value to variable .

[example]

class foo: public ComponentBase
{
	COMPONENT(foo, ComponentBase);
	PROP_NAME("foo");

	COMPONENT_INIT(init);
	COMPONENT_UPDATE(update);

protected:
	void init();
	void update();
public:
	int value = 0;
  	void method();
}
//-------------------------------------------------------------

<Some Class's Update()>
  SomeClass::Update()
  {
  	foo* it = getComponent<foo>(someNode->findNode("foo_Node", 1));		// return nullptr, There is no problem with "someNode" used to obtain the foo class.
    it->method();													// did not occur error, and fuction work
    it->value = 3;													// did not occur error, but vlaue not changed.
  }

 

I'm not sure where the problem started.

Edited by dongju.jeong
Posted

The "problem" is started in C++ itself :) You can call methods from nullptr and nothing will indicates that you are doing some terribly wrong things.

More info you can check here:

How to submit a good bug report
---
FTP server for test scenes and user uploads:

  • silent changed the title to [SOLVED] Using class instances related to the component system.
×
×
  • Create New...