Hi Robert,

i have tested you tip, but it in my case it seems not to work.
I only call the setText() method via my NodeVisitor, also run the viewer in SingleThreaded mode, and set text->setDataVariance(osg::Object::DYNAMIC).
what else could be wrong?

David
Hi David,

Best guess would be that you are running the viewer multi-threaded
(it's default if you have a multicore processor) and the update
traversal to the text is occurring at the same time as the draw
traversal that is reading.  The solution is to tell the scene graph
that you plan to dynamically update the text object so that it knows
not to overlap the update/event and draw traversals.  You can do this
by using text->setDataVariance(osg::Object::DYNAMIC);

Robert.

On 10 January 2013 16:41, DavidHornung <horn...@googlemail.com> wrote:
Hello,
i have a seg fault because the osgText::Text::setText(std::string) is not
thread-save.
It appears from type to time

Why get I this seg fault sometimes?

I have the following setup

class ObjectGroup : public osg::Group
{
...
     ObjectGroup()
    {
         ...
         text = osgText::Text;
         ....
         this->addChild(text);
         this->setUpdateCallback(new ObjectNodeCallback);
    }

//called from NodeCallback
    void updateText()
    {
          text->setText(myText);
     }

private:
     osgText::Text text;
     std::String myText;
...
};

class ObjectNodeCallback : public osg::NodeCallback
{
      //override
      operator ()(osg::Node* node, osg::NodeVisitor* nv)
      {
              osg::ref_ptr<ObjectGroup> obj =
dynamic_cast<ObjectGroup*>(node);
              obj->updateText();
              traverse(node, nv);
      }
};


Cheers,
David
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to