From b15f4399f4a6752a8180cb0472de11c36d808a15 Mon Sep 17 00:00:00 2001 From: Vladimir Belyavsky Date: Sat, 20 Apr 2024 10:49:53 +0300 Subject: [PATCH] QMetaTypeCustomRegistry: use QHash::removeIf() instead of a custom erasing loop Use QHash::removeIf() instead of a custom erasing loop on aliases table when unregister custom type. It will still always detach even if nothing needs to be removed, since QHash::removeIf() always detaches. But this can potentially be fixed in the future, so it will be improved indirectly. Besides other things this also silences Clazy's "mixing iterators" warning. Change-Id: I3d6e8b0ed7dc10807570a0b0feac7eda6a0e572a Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 6c47f2e69d..387c0f49ab 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -150,13 +150,7 @@ struct QMetaTypeCustomRegistry auto &ti = registry[idx]; // We must unregister all names. - auto it = aliases.begin(); - while (it != aliases.end()) { - if (it.value() == ti) - it = aliases.erase(it); - else - ++it; - } + aliases.removeIf([ti] (const auto &kv) { return kv.value() == ti; }); ti = nullptr;