diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index ebac29f14..af4ddf29a 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -37,17 +37,23 @@ namespace Plasma { -typedef QHash > TexturesCache; +typedef QHash > > TexturesCache; Q_GLOBAL_STATIC(TexturesCache, s_cache) QSharedPointer loadTexture(QQuickWindow *window, const QImage &image) { qint64 id = image.cacheKey(); - QSharedPointer texture = s_cache->value(id).toStrongRef(); + QSharedPointer texture = s_cache->value(id).value(window).toStrongRef(); if (!texture) { - auto cleanAndDelete = [id](QSGTexture* texture) { s_cache->remove(id); delete texture; }; + auto cleanAndDelete = [window, id](QSGTexture* texture) { + QHash >& textures = (*s_cache)[id]; + textures.remove(window); + if (textures.isEmpty()) + s_cache->remove(id); + delete texture; + }; texture = QSharedPointer(window->createTextureFromImage(image), cleanAndDelete); - s_cache->insert(id, texture.toWeakRef()); + (*s_cache)[id][window] = texture.toWeakRef(); } return texture; }