Made the new global state attribute instances in osg::State use osg:ref_ptr

to automatically handle the memory deletion.
This commit is contained in:
Robert Osfield 2001-10-15 14:29:40 +00:00
parent 59077fed15
commit 5de4e8e6d8

View File

@ -143,7 +143,7 @@ class SG_EXPORT State : public Referenced
/** apply an attribute if required, passing in attribute and appropriate attribute stack */
bool changed;
const StateAttribute* last_applied_attribute;
StateAttribute* global_default_attribute;
ref_ptr<StateAttribute> global_default_attribute;
AttributeVec attributeVec;
};
@ -168,7 +168,7 @@ class SG_EXPORT State : public Referenced
{
if (as.last_applied_attribute != attribute)
{
if (!as.global_default_attribute) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->clone());
if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->clone());
as.last_applied_attribute = attribute;
attribute->apply(*this);
@ -180,10 +180,10 @@ class SG_EXPORT State : public Referenced
inline const bool apply_global_default_attribute(AttributeStack& as)
{
if (as.last_applied_attribute != as.global_default_attribute)
if (as.last_applied_attribute != as.global_default_attribute.get())
{
as.last_applied_attribute = as.global_default_attribute;
if (as.global_default_attribute) as.global_default_attribute->apply(*this);
as.last_applied_attribute = as.global_default_attribute.get();
if (as.global_default_attribute.valid()) as.global_default_attribute->apply(*this);
return true;
}
else