From 0da7e0fa8fa0f4e216899e24b3cedf1e09759628 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 12 Dec 2013 17:33:09 +0100 Subject: 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 --- src/corelib/kernel/qmetatype.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/corelib') 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(*src)); + } static void advance(void **iterator, int step) { @@ -812,6 +816,10 @@ struct IteratorOwner { *ptr = const_cast(iterator); } + static void assign(void **ptr, void * const * src) + { + *ptr = static_cast(*src); + } static void advance(void **iterator, int step) { @@ -942,7 +950,7 @@ public: template static void copyIterImpl(void **dest, void * const * src) - { IteratorOwner::assign(dest, *static_cast(*src)); } + { IteratorOwner::assign(dest, src); } public: template QSequentialIterableImpl(const T*p) @@ -1122,7 +1130,7 @@ public: template static void copyIterImpl(void **dest, void * const * src) - { IteratorOwner::assign(dest, *static_cast(*src)); } + { IteratorOwner::assign(dest, src); } public: template QAssociativeIterableImpl(const T*p) -- cgit v1.2.3