[Interest] Scene graph custom component with dynamic pieces

Nathan Frana frananathan at gmail.com
Sat Nov 3 02:23:55 CET 2018


All,

I'm a bit of a Qt novice but I have been working on a custom gauge with a
dynamic number of ticks, all drawn in updatePaintNode. The Node hierarchy
is like this:
QSGNode (root/old node)
--> QSGGeometryNode (Background)
--> QSGGeometryNode (Border/Edge)
--> QSGNode (Tick Container)
-----> QSGGeometryNode (n # of ticks)

The issue comes when it needs to be updated, both the background and border
geometries are kept as pointers and can be easily changed without having to
recreate the nodes, but the ticks have to be removed and created again. I
used the removeAllChildren on the Tick Container Node, then created all new
children afterwards. In reality the end result works all fine and dandy,
except for a memory leak I traced to be located when creating the new ones
but it could be leftover from deletion of the old.
>From my understanding, adding the flags OwnsGeometry and OwnsMaterial on
the generated GeometryNodes should handle the deletion of the material and
geometry when the node is removed using removeAllChildren and that exiting
the updatePaintNode should have handled all pointers to QSGGeometryNodes,
QSGGeomtries and QSGFlatColorMaterials. My suspicion is that these
Geometries and Materials are not getting freed, causing the leak.

Is there something I am missing when removing and creating new nodes that
should be done or is there a better way going about this?

Thanks,
Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181102/85b1bc1a/attachment.html>


More information about the Interest mailing list