-
QVector clear()
Hi,
I have a Vector containing GeometricObject pointers. (3d objects I use in my raytracer program). I was wondering if when I call clear() on the vector, only the items of the vector are destroyed or also the GeometricObjects itself are deleted?
Or do I have to clean the pointers and delete the GeometricObjects to avoid memory leaks manually?
-
Re: QVector clear()
Of course you have to.
Since clear delete the objects managed by your container, it deletes only the pointer and not the objects pointed.
-
Re: QVector clear()
The qDeleteAll() function from QtAlgorithms might become handy...
-
Re: QVector clear()
Or maybe your objects are managed by a parent, like a lot of widgets in Qt class hierachy, that are deleted by the owner.
-
Re: QVector clear()
Nope, they are my own objects (no QObjeccts). But QtAlgorithms looks handy ;-)