summaryrefslogtreecommitdiffstats
path: root/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/adaptationlayers/qsgpartialuploadtexturemanager.cpp')
-rw-r--r--src/adaptationlayers/qsgpartialuploadtexturemanager.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp b/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
index ba162c3..2696eeb 100644
--- a/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
+++ b/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
@@ -49,10 +49,19 @@ class QSGPartialUploadTexture : public QSGTexture
{
Q_OBJECT
public:
+ QSGPartialUploadTexture(QSGPartialUploadTextureManager *m)
+ : manager(m)
+ {
+ }
+
+ ~QSGPartialUploadTexture();
+
int chunkCount;
int progress;
QImage image;
+
+ QSGPartialUploadTextureManager *manager;
};
@@ -77,6 +86,12 @@ public:
QList<QSGPartialUploadTexture *> requests;
};
+QSGPartialUploadTexture::~QSGPartialUploadTexture()
+{
+ manager->d_func()->requests.removeOne(this);
+ manager->d_func()->removeTextureFromCache(this);
+}
+
QSGPartialUploadTextureManager::QSGPartialUploadTextureManager()
: QSGTextureManager(*(new QSGPartialUploadTextureManagerPrivate))
@@ -102,7 +117,7 @@ QSGTextureRef QSGPartialUploadTextureManager::requestUpload(const QImage &image,
if (texture)
return QSGTextureRef(texture);
- QSGPartialUploadTexture *ptex = new QSGPartialUploadTexture;
+ QSGPartialUploadTexture *ptex = new QSGPartialUploadTexture(this);
ptex->progress = 0;
ptex->image = image;
@@ -133,7 +148,7 @@ QSGTextureRef QSGPartialUploadTextureManager::upload(const QImage &image)
if (texture) {
QSGPartialUploadTexture *ptex = qobject_cast<QSGPartialUploadTexture *>(texture);
- if (ptex && ptex->progress == ptex->chunkCount || !ptex) {
+ if ((ptex && ptex->progress == ptex->chunkCount) || !ptex) {
// Already fully uploaded... Just return
return QSGTextureRef(texture);