Revert "Partial fix for crash in SGPropertyNode::fireValueChanged"
This reverts commit f33ad357e9.
This commit is contained in:
@@ -1356,28 +1356,6 @@ void Effect::InitializeCallback::doUpdate(osg::Node* node, osg::NodeVisitor* nv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Effect::UpdateCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
|
||||||
{
|
|
||||||
EffectGeode* eg = dynamic_cast<EffectGeode*>(node);
|
|
||||||
if (!eg)
|
|
||||||
return;
|
|
||||||
Effect* effect = eg->getEffect();
|
|
||||||
if (!effect)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (vector<SGSharedPtr<Updater> >::iterator itr = effect->_extraData.begin(),
|
|
||||||
end = effect->_extraData.end();
|
|
||||||
itr != end;
|
|
||||||
++itr) {
|
|
||||||
PropertyPoller * poller
|
|
||||||
= dynamic_cast<PropertyPoller*>(itr->ptr());
|
|
||||||
if (poller)
|
|
||||||
poller->pollProperties(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
traverse(node, nv);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Effect::Key::EqualTo::operator()(const Effect::Key& lhs,
|
bool Effect::Key::EqualTo::operator()(const Effect::Key& lhs,
|
||||||
const Effect::Key& rhs) const
|
const Effect::Key& rhs) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,17 +73,6 @@ private:
|
|||||||
bool _initialized;
|
bool _initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PropertyPoller
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PropertyPoller() {};
|
|
||||||
virtual ~PropertyPoller() {};
|
|
||||||
virtual void pollProperties(Effect* effect)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
class Effect : public osg::Object
|
class Effect : public osg::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -132,17 +121,6 @@ public:
|
|||||||
{
|
{
|
||||||
void doUpdate(osg::Node* node, osg::NodeVisitor* nv);
|
void doUpdate(osg::Node* node, osg::NodeVisitor* nv);
|
||||||
};
|
};
|
||||||
friend struct UpdateCallback;
|
|
||||||
struct UpdateCallback : public osg::NodeCallback
|
|
||||||
{
|
|
||||||
UpdateCallback() {}
|
|
||||||
UpdateCallback(const UpdateCallback& nc, const osg::CopyOp& copyop)
|
|
||||||
: osg::NodeCallback(nc, copyop)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
|
|
||||||
};
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<SGSharedPtr<Updater> > _extraData;
|
std::vector<SGSharedPtr<Updater> > _extraData;
|
||||||
~Effect();
|
~Effect();
|
||||||
|
|||||||
@@ -496,17 +496,19 @@ make_OSGFunctor(Obj* obj, void (Obj::*const func)(const OSGParam&))
|
|||||||
template<typename OSGParamType, typename ObjType, typename F>
|
template<typename OSGParamType, typename ObjType, typename F>
|
||||||
class ScalarChangeListener
|
class ScalarChangeListener
|
||||||
: public SGPropertyChangeListener, public InitializeWhenAdded,
|
: public SGPropertyChangeListener, public InitializeWhenAdded,
|
||||||
public PropertyPoller,
|
|
||||||
public Effect::Updater
|
public Effect::Updater
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScalarChangeListener(ObjType* obj, const F& setter,
|
ScalarChangeListener(ObjType* obj, const F& setter,
|
||||||
const std::string& propName)
|
const std::string& propName)
|
||||||
: _obj(obj), _setter(setter), _propName(propName)
|
: _obj(obj), _setter(setter)
|
||||||
{
|
{
|
||||||
|
_propName = new std::string(propName);
|
||||||
}
|
}
|
||||||
virtual ~ScalarChangeListener()
|
virtual ~ScalarChangeListener()
|
||||||
{
|
{
|
||||||
|
delete _propName;
|
||||||
|
_propName = 0;
|
||||||
}
|
}
|
||||||
void valueChanged(SGPropertyNode* node)
|
void valueChanged(SGPropertyNode* node)
|
||||||
{
|
{
|
||||||
@@ -514,20 +516,16 @@ public:
|
|||||||
}
|
}
|
||||||
void initOnAddImpl(Effect* effect, SGPropertyNode* propRoot)
|
void initOnAddImpl(Effect* effect, SGPropertyNode* propRoot)
|
||||||
{
|
{
|
||||||
_listenProp = makeNode(propRoot, _propName);
|
SGPropertyNode* listenProp = makeNode(propRoot, *_propName);
|
||||||
// if ( _listenProp.valid() )
|
delete _propName;
|
||||||
// _listenProp->addChangeListener(this, true);
|
_propName = 0;
|
||||||
}
|
if (listenProp)
|
||||||
void pollProperties(Effect* effect)
|
listenProp->addChangeListener(this, true);
|
||||||
{
|
|
||||||
if( false == _listenProp.valid() ) return;
|
|
||||||
valueChanged(_listenProp);
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
SGPropertyNode_ptr _listenProp;
|
|
||||||
osg::ref_ptr<ObjType> _obj;
|
osg::ref_ptr<ObjType> _obj;
|
||||||
F _setter;
|
F _setter;
|
||||||
std::string _propName;
|
std::string* _propName;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename Func>
|
template<typename T, typename Func>
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ void EffectGeode::setEffect(Effect* effect)
|
|||||||
_effect = effect;
|
_effect = effect;
|
||||||
if (!_effect)
|
if (!_effect)
|
||||||
return;
|
return;
|
||||||
//TODO: do we leak the callbacks or does the geode own pointer afterwards?
|
|
||||||
addUpdateCallback(new Effect::InitializeCallback);
|
addUpdateCallback(new Effect::InitializeCallback);
|
||||||
addUpdateCallback(new Effect::UpdateCallback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectGeode::resizeGLObjectBuffers(unsigned int maxSize)
|
void EffectGeode::resizeGLObjectBuffers(unsigned int maxSize)
|
||||||
|
|||||||
Reference in New Issue
Block a user