summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2024-04-20 10:49:53 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2024-04-21 08:08:39 +0300
commitb15f4399f4a6752a8180cb0472de11c36d808a15 (patch)
tree2256d4cb3a5304e552331feb45d9828f5e19e7c9 /src/corelib
parent5ad12ab57d975d0e031c74138e90a4d81a32c54f (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qmetatype.cpp8
1 files changed, 1 insertions, 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;