Project

General

Profile

Coding Standards

Lua

Media objects

Always use new when constructing a new media object and do not use delete on these objects.

Explanation: The situation is a little strange due to OSG’s use of so called smart pointers. Lua isn’t aware of smart pointers though so its references don’t increment the reference count. When you remove an object from a context, and it’s not on any other context, the smart pointer doesn’t think any references remain and an implicit delete occurs under the covers. Then your explicit delete (or that during Lua garbage collection) results in a double delete, which is usually a segfault.

Be sure to always remove media objects from a context when no longer needed since that’s what ultimately frees them. This avoids memory leaks.

For media contexts you should either call delete or not use new and let the garbage collector remove them.

Git

All source repositories are now hosted in Git version control. Helpful git aliases.