tolga Posted March 30, 2020 Share Posted March 30, 2020 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
andrey-kozlov Posted March 30, 2020 Share Posted March 30, 2020 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
tolga Posted March 30, 2020 Author Share Posted March 30, 2020 Ok thanks. That was my second option to use shared_ptr :) Link to comment
Recommended Posts