Qt World Summit: Register Today!

Handling graphics resources

  • Hi,

    I've been reading the Graphics Resource Section on this page, but I'm not sure how to handle the following situation. I've created a custom QML item that uses some custom openGL code (it creates it's own texture for example). I want to delete this texture and some other resources when QQuickItem::releaseResources() is called. Currently I schedule a render job with AfterRenderingStage to make sure the GL context is available. The cleanup works fine and my render job is executed. Though, directly after my job has been executed, my QQuickWindow::beforeRendering slot is called again. In my beforeRendering slot, I draw using the texture; but because it's removed (i.e. my render job has been executed in which I remove my textures), my app crashes because it tries to use cleaned up resources.

    I'm curious how I should handle the situation where QQuickWindow::releaseResources() is called. For example do I need to disconnect from the QQuickWindow::beforeRendering signal?