Hi Robert,

The code is fine, the compiler is trying to be clever in case a possible 
errant use of C++, but isn't so clever as to see that the new'd object is 
being immediately assigned to a smart pointer. It should be possible to 
quieten down this type of warnings in the compiler.  Alternatively perhaps 
the compiler can be quietened down by doing:

   osg::ref_ptr<osg::Node> node(new osg::Node);

With the successor to the OpenSceneGraph, the VulkanSceneGraph I've also 
implemented an equivalent of osg::ref_ptr<> and also works with intrusive 
reference counting, but to help avoid the need for new calls I've 
implemented a Object::create() method that does the new and returns a 
vsg::ref_ptr<> for you. This allows you to do:

     auto node = vsg::Node::create(); // does a new Node and returns 
vsg::ref_ptr<vsg::Node>

I've also tweak vsg::ref_ptr<> so it doesn't allow straight C pointer 
assigned, to try and catch possible new misuse, I'm not entirely convinced 
it's a really sound restriction, but am trying it out to see what the 
impact is on day to day coding.

For the OSG, it's over 20 years old, and is in maintenance mode, so major 
changes that could break user code aren't on the table.  A tweak like 
adding a osg::Node::create() style usage might be possible to retrofit to 
the META_Node macro but replacing all new usage in the OSG code base would 
be a huge endeavour and likely fraught with potential error.

Cheers,
Robert.

-- 
You received this message because you are subscribed to the Google Groups 
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/40589218-ebc5-4472-9bcb-832eaa64c7a0n%40googlegroups.com.

Reply via email to