HI Filippo,

There really isn't enough information to know what might be wrong.
The best that others like myself can do at this stage is provide
general advice on threading.

Your code doesn't have or mention any mutex, you'll need to use this
to avoid problems with the two threads reading/writing to the same
data at the same time.

Second the osg::Image you are sharing the data pointer which "might"
be safe in very specific usage models but isn't generally safe as
there is nothing stopping the application from deleting this image
data, it could well be that your original data object gets deleted
leaving this osg::Image with a dangling pointer.

For future reference, what you have crashes and want a bit of feedback
on what might be the cause, it's best to provide a stack trace as this
gives lots of clues to what might be wrong.

Cheers,
Robert.

On 5 July 2013 08:45, Filippo Fontanelli <[email protected]> wrote:
> Hi,
>
> I'm trying to create a buffer of osg :: image, which will be shared between 2 
> threads.
>
> The problem is that when I try to remove an image from the buffer (list)
> my application terminated.
>
>
> Post here a simple code:
>
>
>
> Code:
>
> Qlist<osg::ref_prt<Osg::Image> > m_ListImage;
>
> m_QImage = QImage(m_MatImage.data,m_MatImage.cols, m_MatImage.rows, 
> (int)(*m_MatImage.step.p),QImage::Format_RGB888);
>
> m_QGLImage = QGLWidget::convertToGLFormat(m_QImage);
> unsigned char* data = m_QGLImage.bits();
>
> m_OsgImage = new osg::Image;
> m_OsgImage->setImage(m_QGLImage.width(), m_QGLImage.height(), 1, 4, GL_RGBA, 
> GL_UNSIGNED_BYTE,  data,  osg::Image::NO_DELETE, 1);
>
> m_ListImage.append(m_OsgImage);
>
> while (m_ListImage.count() > 10)
> {
> m_ListImage.removeFirst();
> }
>
>
>
>
> Thank you!
>
> Cheers,
> Filippo[/code]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=55147#55147
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to