[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO
Marc Mutz
marc.mutz at kdab.com
Fri Jul 10 13:34:12 CEST 2015
On Friday 10 July 2015 13:29:30 Marc Mutz wrote:
> On Friday 10 July 2015 12:18:04 Smith Martin wrote:
> > ...it will create each list entry as a QList<ParsedParameter*> even
> > though I told it not to do that?
>
> Yes. But you told it to do that. You used a _list_.
Ok, I take the bait:
QList is primarily a list, not an array (thus the name). That means that, by
default, references to elements in the list are never invalidated until the
element is removed again. The problem started when someone optimised QList to
contain the elements in an array, but only for *some* types. So, depending on
the type and the QTypeInfo for that flag, QList is either like a std::list or
like a std::vector (QLinkedList / QVector in Qt speak). And it takes great
mental discipline to use it in the proper way, and the resulting code will be
highly fragile and/or extremely inefficient.
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
More information about the Development
mailing list