Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Program crashes with custom ImageItem and renderTarget == QQuickPaintedItem::FramebufferObject
gs_chris last edited by
I have an app that keeps a dynamically generated list of images in a ListView. The images are generated from backend data and exist in the form of QImage objects. In order to display them, I had to create a custom Item (subclassed off QQuickPaintedItem). This initially seemed to work well, but after a while I began to encounter random crashes when resizing the app window (I recompute the image list to fit the window size). The debugger stack showed only Qt functions, and the actual crash seemed to happen inside OpenGL driver code. There was no obvious connection to my code.
After 2 days of wading through my code and trying to find any irregularity, I found that by commenting out one line of code I was able to avoid the crashes: This line is inside the constructor of my ImageItem class, and it reads:
It seems that setting that flag (which supposedly yields performance improvements) causes the random crashes I was encountering. I have come to conclude that this is a very nasty Qt/QML bug.
Warning: Resizing a framebuffer object is a costly operation, avoid using the QQuickPaintedItem::FramebufferObject render target if the item gets resized often.