Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
3d and threads
I'm switching over from OpenSceneGraph to Qt3d, but as soon as I started setting up I ran into the following issue:
Qt3DCore::QEntity* lightEntity = new Qt3DCore::QEntity(m_rootEntity); Qt3DRender::QPointLight* light = new Qt3DRender::QPointLight(m_rootEntity); lightEntity->addComponent(light);
Yields an error stating that I cannot assign a parent from a different thread. I'm familiar with this issue when working with different threads explicitly, but in this case Qt3DCore and Qt3DRender run in different threads by design I assume.
Anyone encounter a similar issue? and if so any advice?
(I am using Qt 5.7 under Visual Studio 2015, with multithreaded dll)
Yields an error stating that I cannot assign a parent from a different thread.
Are you sure that's this piece of code that's causing it?
I'm familiar with this issue when working with different threads explicitly, but in this case Qt3DCore and Qt3DRender run in different threads by design I assume.
Under the hood, but not for the interface (i.e. public) objects.
Re: 3d and threads
Stepping through the program shows that the errors come from here. There is also the error message that explicitly names the threads.
I'm not sure what happens under the hood, but again stepping through I can easily see the 2 extra threads, which have been instantiated at some point.
I loaded a bare bone example with similar code and it doesn't do that. Perhaps it's because I have this encapsulated in a class, though I don't see how.
Perhaps it's because I have this encapsulated in a class, though I don't see how.
No it shouldn't be that. What about the root entity, any funny thing you might be doing with it? Perhaps moving it into a thread by means of
Tried that but failed later on (corruption, so must be doing something really wrong).
I loaded a similar example (the basic-shape-cpp included in the distrib) project and put in a breakpoint, and I see both threads in addition to the main GUI. No warning though.
I tried removing the light to just see what it can draw and I run into a heap corruption. Must be something else. I'll update if I find something.
That's really odd. Could you paste your example code that reproduces this?
It's the exact code in the example of the distrib.
So I got everything to work after comparing the project options with the one from the converted .pro. One of these options must have caused it, I'll try to isolate it and post it here.
Yes, thanks for that. It may help someone else tracking a similar problem.
I couldn't isolate exactly what was causing it because it's taking a very long time to try out different combinations, but I know it was either one of the QT preprocessor directives (perhaps the QT_OPENGL being placed before something else) or the order of the link libraries (I was missing one of the 3d ones too, but didn't get any linking error).
I currently have the libraries & directives given as most specialized to least and it seems to solve the issue.
Thanks for the help