diff options
-rw-r--r-- | src/graphicsitems/qximagebase.cpp | 23 | ||||
-rw-r--r-- | src/scenegraph/coreapi/qsgtexturemanager.cpp | 18 |
2 files changed, 26 insertions, 15 deletions
diff --git a/src/graphicsitems/qximagebase.cpp b/src/graphicsitems/qximagebase.cpp index 64d27e3..81ef269 100644 --- a/src/graphicsitems/qximagebase.cpp +++ b/src/graphicsitems/qximagebase.cpp @@ -191,20 +191,19 @@ void QxImageBase::requestFinished() if (d->progress != oldProgress) emit progressChanged(d->progress); + if (d->status != Error && d->status != Null) { + QSGTextureManager *tm = QSGContext::current->textureManager(); + if (d->async) { + QImage image = d->pix.pixmap().toImage(); + d->texture = tm->requestUpload(image, + this, + SLOT(textureStatusChanged(int))); - QSGTextureManager *tm = QSGContext::current->textureManager(); - - if (d->async) { - QImage image = d->pix.pixmap().toImage(); - d->texture = tm->requestUpload(image, - this, - SLOT(textureStatusChanged(int))); - - } else { - d->texture = tm->upload(d->pix.pixmap().toImage()); + } else { + d->texture = tm->upload(d->pix.pixmap().toImage()); + } + markDirty(QxImageBasePrivate::DirtyTextureReady); } - - markDirty(QxImageBasePrivate::DirtyTextureReady); } void QxImageBase::textureStatusChanged(int status) diff --git a/src/scenegraph/coreapi/qsgtexturemanager.cpp b/src/scenegraph/coreapi/qsgtexturemanager.cpp index b807977..d8c08f8 100644 --- a/src/scenegraph/coreapi/qsgtexturemanager.cpp +++ b/src/scenegraph/coreapi/qsgtexturemanager.cpp @@ -152,6 +152,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; + } + } + } @@ -170,6 +179,8 @@ void QSGTextureManager::swizzleBGRAToRGBA(QImage *image) QSGTextureRef QSGTextureManager::upload(const QImage &image) { + Q_ASSERT(!image.isNull()); + QSGTextureCacheKey key = { image.cacheKey() }; QSGTexture *texture = d->cache.value(key); if (texture) @@ -206,8 +217,11 @@ QSGTextureRef QSGTextureManager::requestUpload(const QImage &image, const QObject *listener, const char *slot) { + Q_ASSERT(!image.isNull()); + 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 +296,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; |