Re: [osg-users] Bug in Qt thread integration

2013-01-24 Thread Vitezslav Zajic
Hi,

I have run into the same problem with the application I'm working on. Since it 
seems to me that it was not corrected yet (or am I mistaken?), i'm writing 
here. I suggest that at least the static_cast is replaced with the dynamic_cast:


Code:
QtThreadPrivateData* pd = 
static_castQtThreadPrivateData*(QThread::currentThread());



It helped in my case (everything seems to be working), and, if there is still 
some bug caused by the possibly returned null pointer, it will be at least more 
easily trackable.

Note that this can be reproduced if you use single-threaded rendering in the 
application's main thread. The main thread is created by Qt, not by 
OpenThreads, and is not an instance of QtThreadPrivateData.

Cheers,
Vitezslav

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=52021#52021





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


Re: [osg-users] Bug in Qt thread integration

2012-10-03 Thread Chris Long
Hi,

Thanks for the replies and suggestions.

I think I might not have explained the issue as well as I thought, so I'll try 
again.

QThread::currentThread does return a value with static type QThread*. However, 
it might not point to a QThread instance, but an instance of a subclass of 
QThread.

The problem is that OpenThreads assumes that the return value can be cast to a 
pointer to a specific subclass of QThread that OpenThreads defines, 
QtThreadPrivateData, like this:


Code:
QtThreadPrivateData* pd = 
static_castQtThreadPrivateData*(QThread::currentThread());




This is a problem because if the current thread is a different subclass of 
QThread, this cast is invalid so when the new pointer (pd) is used, it causes a 
seg fault or random behavior.

We have observed in our application that this does in fact sometimes occur. 
Specifically, QThread::currentThread can return a QAdoptedThread*, which is 
legal since QAdoptedThread is a subclass of QThread.

I hope this clarifies things.

Thank you!

Cheers,
Chris

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50392#50392





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


Re: [osg-users] Bug in Qt thread integration

2012-09-28 Thread Torben Dannhauer
Hi,

In fact QThread::currentThread returns a QThread.

maybe you want to use qobject_cast instead of other casts, it is has some other 
advantages 
(http://lists.qt.nokia.com/pipermail/qt-interest/2010-October/028327.html).

Cheers,
Torben

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50341#50341





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


Re: [osg-users] Bug in Qt thread integration

2012-09-27 Thread Aurelien Albert
Hi,

I'm surprised that QThread::currentThread() can return something else than a 
QThread instance.

But if this is really the case, the following should solve the issue :


Code:
QThread* pQThread = dynamic_cast QThread* (QThread::currentThread());
if (pQThread != NULL)
{
   QtThreadPrivateData* pd = static_cast QtThreadPrivateData (pQThread);
}




--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50337#50337





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