Avoid unnecessary detaching of the pending deletions list.

This code seems to be hit three times per frame in a hybrid QQ2/Qt3D app,
quickly generating thousands of allocations here via the detach in begin().

Heaptrack confirms they are all gone now.

Change-Id: I7d09f3f5c2b24a2590b701216715055751306e82
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Volker Krause 2016-01-05 15:17:11 +01:00
parent daeed4631a
commit b1dcdc4064

View File

@ -1459,11 +1459,11 @@ void QOpenGLContextGroupPrivate::deletePendingResources(QOpenGLContext *ctx)
{
QMutexLocker locker(&m_mutex);
QList<QOpenGLSharedResource *> pending = m_pendingDeletion;
const QList<QOpenGLSharedResource *> pending = m_pendingDeletion;
m_pendingDeletion.clear();
QList<QOpenGLSharedResource *>::iterator it = pending.begin();
QList<QOpenGLSharedResource *>::iterator end = pending.end();
QList<QOpenGLSharedResource *>::const_iterator it = pending.begin();
QList<QOpenGLSharedResource *>::const_iterator end = pending.end();
while (it != end) {
(*it)->freeResource(ctx);
delete *it;