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>
This commit is contained in:
parent
4449148395
commit
0da7e0fa8f
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user