[Development] implicit sharing and iterators in qt containers

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon Jul 31 06:15:33 CEST 2017


Hi All,

I recently stumbled upon an issue where using iterators of a QLinkedList,
altered the "copy" of another QLinkedList.

On reading the iterator docs, I came across this limitation of Qt
containers with implicit sharing:
http://doc.qt.io/qt-5/containers.html#implicit-sharing-iterator-problem

Basically this article advises against making copies of containers which
have active iterators on them.

I've written a Qt based "ordered map" which uses a QLinkedList for
maintaining order of keys (https://github.com/mandeepsandhu/qt-ordered-map).
However, due to the issue with implicit sharing & iterators, it's not
possible for a trivial assignment operator & copy c'tor. Is there any way
around it other than making a item-by-item copy of the linked list?

Thanks,
-mandeep
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170730/e814abea/attachment.html>


More information about the Development mailing list