aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2024-09-02 15:43:11 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-09-05 03:17:31 +0000
commit3fe6c2c8cb63adbbd0531663677ea6d361c304aa (patch)
treefa98197bd14c2d095b1fbf2601366da8b99117b0
parent0ba440a291159adb76394e5cbd53d13e92306cc4 (diff)
Curve renderer: Fix crash when root node is replaced
A curve renderer instance keeps references to the fill and stroke nodes it has created, in order to facilitate maintaining correct rendering order when updating. All nodes are children of the renderer's root node. It can happen, like when hiding and re-showing a Popup, that the renderer instance is assigned a new root node. The references to the child nodes are then invalid, and accessing them will fail. Fix by clearing all such references when a new root node is set. Fixes: QTBUG-128561 Change-Id: Ibc4992780867049e9e38a2bf1a163eed79bdc5c0 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit cef3ff0a60d37615a5230a84ad172b357897fe7e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit e20e91904a5131269196a1c7596fb05959fb5761)
-rw-r--r--src/quickshapes/qquickshapecurverenderer.cpp9
-rw-r--r--src/quickshapes/qquickshapecurverenderer_p.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/quickshapes/qquickshapecurverenderer.cpp b/src/quickshapes/qquickshapecurverenderer.cpp
index acda4e4945..d45a120749 100644
--- a/src/quickshapes/qquickshapecurverenderer.cpp
+++ b/src/quickshapes/qquickshapecurverenderer.cpp
@@ -655,9 +655,18 @@ QQuickShapeCurveRenderer::NodeList QQuickShapeCurveRenderer::addTriangulatingStr
void QQuickShapeCurveRenderer::setRootNode(QSGNode *node)
{
+ clearNodeReferences();
m_rootNode = node;
}
+void QQuickShapeCurveRenderer::clearNodeReferences()
+{
+ for (PathData &pd : m_paths) {
+ pd.fillNodes.clear();
+ pd.strokeNodes.clear();
+ }
+}
+
int QQuickShapeCurveRenderer::debugVisualizationFlags = QQuickShapeCurveRenderer::NoDebug;
int QQuickShapeCurveRenderer::debugVisualization()
diff --git a/src/quickshapes/qquickshapecurverenderer_p.h b/src/quickshapes/qquickshapecurverenderer_p.h
index f2b10fb44c..2e8bed4814 100644
--- a/src/quickshapes/qquickshapecurverenderer_p.h
+++ b/src/quickshapes/qquickshapecurverenderer_p.h
@@ -62,6 +62,7 @@ public:
void updateNode() override;
void setRootNode(QSGNode *node);
+ void clearNodeReferences();
using NodeList = QVector<QSGCurveAbstractNode *>;