diff --git a/src/osgPlugins/osgjs/WriteVisitor b/src/osgPlugins/osgjs/WriteVisitor index 4f62155d1..c1e885e49 100644 --- a/src/osgPlugins/osgjs/WriteVisitor +++ b/src/osgPlugins/osgjs/WriteVisitor @@ -211,24 +211,24 @@ public: } void applyCallback(osg::Node& node, JSONObject* json) { - JSONArray* updateCallbacks = new JSONArray; - osg::Callback* nc = node.getUpdateCallback(); + osg::ref_ptr updateCallbacks = new JSONArray; + osg::ref_ptr nc = node.getUpdateCallback(); while (nc) { - osgAnimation::BasicAnimationManager* am = dynamic_cast(nc); + osgAnimation::BasicAnimationManager* am = dynamic_cast(nc.get()); if (am) { - JSONArray* array = new JSONArray; - JSONObject* bam = new JSONObject; + osg::ref_ptr array = new JSONArray; + osg::ref_ptr bam = new JSONObject; bam->getMaps()["Animations"] = array; - JSONObject* nodeCallbackObject = new JSONObject; + osg::ref_ptr nodeCallbackObject = new JSONObject; nodeCallbackObject->getMaps()["osgAnimation.BasicAnimationManager"] = bam; updateCallbacks->getArray().push_back(nodeCallbackObject); for ( unsigned int i = 0; i < am->getAnimationList().size(); i++) { osg::ref_ptr jsonAnim = createJSONAnimation(am->getAnimationList()[i].get()); if (jsonAnim) { - JSONObject* obj = new JSONObject; + osg::ref_ptr obj = new JSONObject; obj->getMaps()["osgAnimation.Animation"] = jsonAnim; array->getArray().push_back(obj); //std::stringstream ss; @@ -237,7 +237,7 @@ public: } } } else { - osgAnimation::UpdateMatrixTransform* updateMT = dynamic_cast(nc); + osgAnimation::UpdateMatrixTransform* updateMT = dynamic_cast(nc.get()); if (updateMT) { osg::ref_ptr jsonCallback = createJSONUpdateMatrixTransform(*updateMT); if (jsonCallback.valid()) {