[Development] Releasing memory after clear() in Qt containers (Qt 5.X)
Kevin Kofler
kevin.kofler at chello.at
Sat Apr 24 01:41:37 CEST 2021
Giuseppe D'Angelo via Development wrote:
> 3) Unrelated to your problem, your code works in Qt 5, but in Qt 6 if
> the QHash gets modified in any way that'll invalidate your entire
> QVector you're keeping as a cache. If you want to future proof your code
> you'll need to redesign that.
This particular issue has come up so frequently in the last few weeks that
this behavior change in Qt 6 sounds like a major design flaw of the Qt 6
QHash to me. Also because it subtly breaks source compatibility in a way the
compiler cannot possibly detect, with the worst possible outcome (undefined
behavior). Only a sophisticated static analysis tool has any chance of
catching this, if a dedicated check is written.
Kevin Kofler
More information about the Development
mailing list