aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-04-07 15:22:16 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-04-07 15:22:16 +0300
commit69c1a1e86b9774fbee6958021055c899151e1955 (patch)
treecf8619fa03e1442b06ee13983d3c3c5d9f307669 /src/imports/controls
parent453e302ea51a9f628ccb1382e812b09f259f890b (diff)
parentc379659f5f51ae14331e5bdd365ef229c9a4c9c9 (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into tqtc/lts-5.15-opensourcev5.15.4-lts-lgpl
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/imagine/qquickninepatchimage.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/imports/controls/imagine/qquickninepatchimage.cpp b/src/imports/controls/imagine/qquickninepatchimage.cpp
index 7d5e4f71..71243988 100644
--- a/src/imports/controls/imagine/qquickninepatchimage.cpp
+++ b/src/imports/controls/imagine/qquickninepatchimage.cpp
@@ -386,7 +386,12 @@ void QQuickNinePatchImage::pixmapChange()
{
Q_D(QQuickNinePatchImage);
if (QFileInfo(d->url.fileName()).completeSuffix().toLower() == QLatin1String("9.png")) {
- d->resetNode = d->ninePatch.isNull();
+ // Keep resetNode if it is already set, we do not want to miss an
+ // ImageNode->NinePatchNode change. Without this there's a chance one gets
+ // an incorrect cast on oldNode every once in a while with source changes.
+ if (!d->resetNode)
+ d->resetNode = d->ninePatch.isNull();
+
d->ninePatch = d->pix.image();
if (d->ninePatch.depth() != 32)
d->ninePatch = d->ninePatch.convertToFormat(QImage::Format_ARGB32);
@@ -449,6 +454,13 @@ QSGNode *QQuickNinePatchImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNode
qsgnode_set_description(patchNode, QString::fromLatin1("QQuickNinePatchImage: '%1'").arg(d->url.toString()));
#endif
+ // The image may wrap non-owned data (due to pixmapChange). Ensure we never
+ // pass such an image to the scenegraph, because with a separate render
+ // thread the data may become invalid (in a subsequent pixmapChange on the
+ // gui thread) by the time the renderer gets to do something with the QImage
+ // passed in here.
+ image.detach();
+
QSGTexture *texture = window()->createTextureFromImage(image);
patchNode->initialize(texture, sz * d->devicePixelRatio, image.size(), d->xDivs, d->yDivs, d->devicePixelRatio);
return patchNode;