简体   繁体   中英

QQuickItem will not render

I'm at my wits end on this bug. Any suggestions on how to track it down would be appreciated.

Background:

I've been trying to implement an ogre3d view as a QQuickItem in Qt5. There's an example (qmlogre) that shows it's possible. The example code needed a great deal of refactoring for Win32 and to do more than just the demo. The example is only a proof of concept.

The problem:

When I call a specific method in the Ogre code (SceneManager::createEntity) the Qt item will no longer render. If I comment out the call to the method it renders fine. If I comment out the code in the method and replace it with 'return 0' it no longer renders. The code in question is not graphics related (it loads a 3d entity into memory).

What I've tried:

  • Checked ogre log where exceptions are shown.
  • redirected Qt logging to a file to see warnings/exceptions.
  • Checked 'this' pointer. I dynamically cast 'this' on entry to the method to the class it was running in and received a non null pointer. So rtti thinks it's a valid class pointer.
  • To ensure the Qt code is right I replaced the custom rendering code from the qmlogre example with code that renders a flat color rectangle.
  • I don't appear to be out of memory

Can I run something this large and complex under valgrind? Are there similar tools that are useful? (Compiler is Mingw as provided by Qt in v5.1 download on Windows 7)

I understand Qt5 is threaded by default. How can you tell if you've exceeded your threads stack size?

Ogre isn't thread safe. Is it possible the Qt code is running on different threads simultaneously and crashing ogre? My code is invoked by an event from QML (it's in a Qt slot).

I don't know Ogre in details, but documentation say Entity class use OpenGL buffers. Then maybe you have conflicts between threads for access OpenGL backend.

Have you try OpenGL Debuggers like GLIntercept or gDEBugger (cf https://www.opengl.org/wiki/Debugging_Tools ) ?

You say that you're loading the object from within QML. By default in Qt 5, this would mean you're loading the object while you're in the Qt worker thread and not in the QML render thread. This doesn't work. All Ogre calls need to be made from the render thread where Ogre was created, otherwise you get undefined behavior.

I'd also recommend checking out my fork of the QML Ogre example at https://github.com/advancingu/QmlOgre . It is the example code you mention but refactored into a library. It's still too early to be anywhere near production ready but you perhaps you can get some ideas for your code from it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM