Jump to content

[SOLVED] Unigine::Ptr in 2.10


photo

Recommended Posts

Hi,

We just migrated to Unigine 2.10. I liked using Unigine::Ptr<T> in 2.9 a lot. From what I see objects are inherited from APIInterface class to use Ptr<T>. Let's say my code looks like this:

// MyObject.h
class MyObject : public APIInterface
{
	static Ptr<MyObject> create();
      
	void doSomething() { }
};

typedef Ptr<MyObject> MyObjectPtr;
      
// MyObject.cpp
MyObjectPtr MyObject::create()
{
      return MyObjectPtr(new MyObject());
}
      
// some cpp
MyObjectPtr o = MyObject::create();
o->doSomething();

When I try to call any function from 'o', the following assertion fails under <UniginePtr.h>

	Type *operator->() const
	{
		assert(!isNull());
		return get();
	}

What am I doing wrong?

Thanks.

Link to comment

Hello,

Unigine::Ptr is not designed to be used for user classes. It has a too way complicated design which is a product of specific requirements such as full insulation, big existing codebase, specific knowledge about engine's objects lifetime managament, etc.
I would recommend you to stick with some other smart ptrs. Standard std::shared_ptr/unique_ptr maybe fairly good default.

Link to comment
  • silent changed the title to [SOLVED] Unigine::Ptr in 2.10
×
×
  • Create New...