From 9e8c1b033e4dc1827b498f3b9596a27d9dcf4a3f Mon Sep 17 00:00:00 2001 From: Paul MARTZ Date: Sat, 4 Jun 2011 00:07:59 +0000 Subject: [PATCH] 2.8 branch: Merge 11959 from trunk. Makes Object::setName() virtual, which fixes an issue with the uniform name ID mechanism. --- include/osg/Object | 8 ++++++-- include/osg/Uniform | 2 +- src/osg/Uniform.cpp | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/osg/Object b/include/osg/Object index 73df9effe..94fd616c7 100644 --- a/include/osg/Object +++ b/include/osg/Object @@ -96,10 +96,14 @@ class OSG_EXPORT Object : public Referenced /** Set the name of object using C++ style string.*/ - inline void setName( const std::string& name ) { _name = name; } + virtual void setName( const std::string& name ) { _name = name; } /** Set the name of object using a C style string.*/ - inline void setName( const char* name ) { _name = name; } + inline void setName( const char* name ) + { + if (name) setName(std::string(name)); + else setName(std::string()); + } /** Get the name of object.*/ inline const std::string& getName() const { return _name; } diff --git a/include/osg/Uniform b/include/osg/Uniform index bc51eddc9..12d44a5fd 100644 --- a/include/osg/Uniform +++ b/include/osg/Uniform @@ -232,7 +232,7 @@ class OSG_EXPORT Uniform : public Object Type getType() const { return _type; } /** Set the name of the glUniform, ensuring it is only set once.*/ - void setName( const std::string& name ); + virtual void setName( const std::string& name ); /** Set the length of a uniform, ensuring it is only set once (1==scalar)*/ void setNumElements( unsigned int numElements ); diff --git a/src/osg/Uniform.cpp b/src/osg/Uniform.cpp index 8f2536f5b..3eb5d0d6d 100644 --- a/src/osg/Uniform.cpp +++ b/src/osg/Uniform.cpp @@ -88,8 +88,8 @@ void Uniform::setName( const std::string& name ) osg::notify(osg::WARN) << "cannot change Uniform name" << std::endl; return; } - _name = name; - _nameID = getNameID(name); + Object::setName(name); + _nameID = getNameID(_name); } void Uniform::setNumElements( unsigned int numElements )