[Qt-interest] Reference of QPixmap is not freed in time in QT opengl paint engine. Maybe a qt opengl paint engine bug???
Trond Kjernåsen
trond.kjernasen at nokia.com
Mon May 10 10:42:06 CEST 2010
Hi,
On 05/10/2010 05:07 AM, Bu, Long wrote:
> 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?
Right, this is a bug in the GL 1 engine (I've created a task for it
http://bugreports.qt.nokia.com/browse/QTBUG-10529). However, it only
applies to pixmaps that are bound using the texture_from_pixmap extension.
Also, is there any particular reason for using the GL 1 engine? The GL 1
engine is considered obsolete and is only running on lifesupport these
days. It's not being actively developed or improved in any manner.
--
Trond K.
More information about the Qt-interest-old
mailing list