diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2013-12-12 17:33:09 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-13 09:28:30 +0100 |
commit | 0da7e0fa8fa0f4e216899e24b3cedf1e09759628 (patch) | |
tree | fd4ac342e6cf57c30fda168c15e7888ba4494647 /src | |
parent | 444914839541154b0927cd1d49890677b8368148 (diff) |
QMetaType: Fix copy of type erased iterator
Behavior differs depending on whether the iterator is a value_type*,
or a different class entirely. Ensure that the correct behavior is
used when copying.
Task-number: QTBUG-33997
Change-Id: Ib6db2a3c4a5aa861b851833a7f0ecb855a3e828f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 06adf7cffd..986d22b5a6 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -783,6 +783,10 @@ struct IteratorOwner { *ptr = new const_iterator(iterator); } + static void assign(void **ptr, void * const * src) + { + *ptr = new const_iterator(*static_cast<const_iterator*>(*src)); + } static void advance(void **iterator, int step) { @@ -812,6 +816,10 @@ struct IteratorOwner<const value_type*> { *ptr = const_cast<value_type*>(iterator); } + static void assign(void **ptr, void * const * src) + { + *ptr = static_cast<value_type*>(*src); + } static void advance(void **iterator, int step) { @@ -942,7 +950,7 @@ public: template<class T> static void copyIterImpl(void **dest, void * const * src) - { IteratorOwner<typename T::const_iterator>::assign(dest, *static_cast<typename T::const_iterator*>(*src)); } + { IteratorOwner<typename T::const_iterator>::assign(dest, src); } public: template<class T> QSequentialIterableImpl(const T*p) @@ -1122,7 +1130,7 @@ public: template<class T> static void copyIterImpl(void **dest, void * const * src) - { IteratorOwner<typename T::const_iterator>::assign(dest, *static_cast<typename T::const_iterator*>(*src)); } + { IteratorOwner<typename T::const_iterator>::assign(dest, src); } public: template<class T> QAssociativeIterableImpl(const T*p) |