[Interest] QList operator[]
Brad Pepers
bpepers at me.com
Fri Jan 9 22:07:53 CET 2015
Ah I see... So it's the const-ness of the object itself and not the reference that is controlling which operator[] gets used. That makes sense to me now.
I'm still not sure what is happening with all that memory though. I'm asking for a reference so I don't expect that I own what is returned yet it seems to be making a deep copy each time and not freeing that memory since in seconds the memory use of the process sky-rockets until the whole system starts thrashing and eventually crashes and burns. Seems odd behaviour to get from a couple of lines of code like that. Would never have expected that to be a memory leak! Makes me wonder if I've done the same kind of mistake in other places where it's not so noticeable...
--
Brad
On Jan 09, 2015, at 01:21 PM, Keith Gardner <kreios4004 at gmail.com> wrote:
QList can return a const & with the [] operator [1]. The documantation even says it's the same as .at().
[1] http://doc.qt.io/qt-5/qlist.html#operator-5b-5d-2
That is true if the QList is const when calling the function. If it is not, the other operator [1] documentation describes the behavior.
[1] http://doc.qt.io/qt-5/qlist.html#operator-5b-5d
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150109/5827620b/attachment.html>
More information about the Interest
mailing list