[Qt-interest] Reference of QPixmap is not freed in time in QT opengl paint engine. Maybe a qt opengl paint engine bug???

Bu, Long long.bu at intel.com
Mon May 10 05:07:16 CEST 2010


A reference of QPixmap is not freed imediately at the end of paint in QT opengl paintengine. 

For an application with lots of pixmaps such as photo viewer, 
if there is a reference of a pixmap, the application can not free the pixmap enven if it is not visible. 
Then the application will consume more and more memory. 

Here is the detail: 

The pixmap is put into a hash table when bindTexture (src/opengl/qgl.cpp).

boundPixmaps.insert(pd, QPixmap(pixmap))

The hash table is only cleared in gl2paintengineex (src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp).

Here are the codes and comments in QGL2PaintEngineEx::end(). 

#if defined(Q_WS_X11)
    // On some (probably all) drivers, deleting an X pixmap which has been bound to a texture
    // before calling glFinish/swapBuffers renders garbage. Presumably this is because X deletes
    // the pixmap behind the driver's back before it's had a chance to use it. To fix this, we
    // reference all QPixmaps which have been bound to stop them being deleted and only deref
    // them here, after swapBuffers, where they can be safely deleted.
    ctx->d_func()->boundPixmaps.clear();
#endif

But there is no such code in QOpenGLPaintEngine::end() (src/opengl/qpaintengine_opengl.cpp). (For meego, we use QOpenGLPaintEngine) 
If the hash table is not cleared, the reference is there and the application can not free the pixmap immediately. 

Do you think it is a bug for QT opengl paint engine?

Thanks!






More information about the Qt-interest-old mailing list