Don't use iterators to temporary containers

Fix a clazy warning, like:
Don't call QVector::begin() on temporary [clazy-temporary-iterator]

Indeed, we may pass begin and end iterators for 2 different
instances of temporary vector (shared though).

In addition: use const iterators.

Change-Id: Iac1055d9fc226f1b48ca72ee4f3aab433addfe7f
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Jarek Kobus
2020-11-18 12:25:51 +01:00
parent f7fa53d29b
commit c9f5ce51e0
3 changed files with 12 additions and 15 deletions

View File

@@ -76,13 +76,13 @@
namespace {
QObject *getPreviewPlugin()
{
auto pluginIt = std::find_if(ExtensionSystem::PluginManager::plugins().begin(),
ExtensionSystem::PluginManager::plugins().end(),
const QVector<ExtensionSystem::PluginSpec *> &specs = ExtensionSystem::PluginManager::plugins();
const auto pluginIt = std::find_if(specs.cbegin(), specs.cend(),
[](const ExtensionSystem::PluginSpec *p) {
return p->name() == "QmlPreview";
});
if (pluginIt != ExtensionSystem::PluginManager::plugins().constEnd())
if (pluginIt != specs.cend())
return (*pluginIt)->plugin();
return nullptr;