From b7cb0613f0dc92a5abfd7eedc44ba9f0ee310cae Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 12 Dec 2013 17:45:34 +0100 Subject: [PATCH] QMetaType: Fix equality comparison of type-erased iterators. Task-number: QTBUG-33997 Change-Id: I0d4da562540df0e3732769881ba124cb980f6b82 Reviewed-by: Simon Hausmann --- src/corelib/kernel/qmetatype.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 986d22b5a6..745487627e 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -808,6 +808,11 @@ struct IteratorOwner { return &*it; } + + static bool equal(void * const *it, void * const *other) + { + return *static_cast(*it) == *static_cast(*other); + } }; template struct IteratorOwner @@ -841,6 +846,11 @@ struct IteratorOwner { return it; } + + static bool equal(void * const *it, void * const *other) + { + return static_cast(*it) == static_cast(*other); + } }; enum IteratorCapability @@ -942,7 +952,7 @@ public: template static bool equalIterImpl(void * const *iterator, void * const *other) - { return *static_cast(*iterator) == *static_cast(*other); } + { return IteratorOwner::equal(iterator, other); } template static VariantData getImpl(void * const *iterator, int metaTypeId, uint flags) @@ -1126,7 +1136,7 @@ public: template static bool equalIterImpl(void * const *iterator, void * const *other) - { return *static_cast(*iterator) == *static_cast(*other); } + { return IteratorOwner::equal(iterator, other); } template static void copyIterImpl(void **dest, void * const * src)