diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2010-12-09 22:00:14 +0100 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2010-12-09 22:00:14 +0100 |
commit | 7d41434b963b9b6e58a80099be686720b3e3098d (patch) | |
tree | 708f56bf547b72345f0c60cfa36b49ce709e0853 | |
parent | d36c40f5c3f2bfecc9e07956d283e4c22c53f708 (diff) |
Fix crash in texture manager.
We had not registerd for the destroyed() signal for textures awaiting to
be uploaded, so when a texture was destroyed before it was properly
uplaoded we would do invalid writes in processAsyncTextures.
-rw-r--r-- | src/scenegraph/coreapi/qsgtexturemanager.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/scenegraph/coreapi/qsgtexturemanager.cpp b/src/scenegraph/coreapi/qsgtexturemanager.cpp index 0b688c3..e729512 100644 --- a/src/scenegraph/coreapi/qsgtexturemanager.cpp +++ b/src/scenegraph/coreapi/qsgtexturemanager.cpp @@ -148,6 +148,15 @@ void QSGTextureManager::textureDestroyed(QObject *destroyed) break; } } + + for (QHash<QSGTextureCacheKey, QSGTexture *>::iterator it = d->cache.begin(); + it != d->cache.end(); ++it) { + if (it.value() == destroyed) { + d->cache.remove(it.key()); + break; + } + } + } @@ -208,6 +217,7 @@ QSGTextureRef QSGTextureManager::requestUpload(const QImage &image, QSGTexture *t = new QSGTexture(); connect(t, SIGNAL(statusChanged(int)), listener, slot); + connect(t, SIGNAL(destroyed(QObject*)), this, SLOT(textureDestroyed(QObject*))); QSGTextureAsyncUpload work; work.image = image; @@ -282,9 +292,7 @@ void QSGTextureManager::processAsyncTextures() } if (time.elapsed() > d->maxUploadTime) - return; - - int steps = 0; + break; while (upload.progress < chunkCount && time.elapsed() < d->maxUploadTime) { int x = (upload.progress % hChunkCount) * d->uploadChunkSize; |