summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@digia.com>2014-06-16 10:24:55 -0400
committerDaniel Teske <daniel.teske@digia.com>2014-06-16 22:47:28 +0200
commit6d2d3ab54d298ebe8d3844ecfc6db19a817d2e62 (patch)
tree9aacc8638ec19ec4414549c0b52b219ff592db57
parente85c6f4b385da2b3da447a4b389dadd3f8d8990f (diff)
downloadqt-creator-6d2d3ab54d298ebe8d3844ecfc6db19a817d2e62.tar.gz
ProjectExplorer: Fix comparing priorities
Makes test_modelmanager_extraeditorsupport_uiFiles pass again. Before, a "CMake Wizard" dialog blocked the auto test due to the wrong comparisons. The std::max_element function takes a less predicate. Thus the right way to find e.g. highest int in a vector is: std::max_element(..., std::less<>) or std::min_element(..., std::greater<>) Both variants are confussing to read. Instead of provinding Utils::maxElementOr provide a bestElementOr which leads to this code: bestElementOr(..., std::greater<>). Change-Id: Ic30f0d742c03170b28227f60d3a5ae00e40fdf5a Reviewed-by: Daniel Teske <daniel.teske@digia.com>
-rw-r--r--src/libs/utils/algorithm.h4
-rw-r--r--src/plugins/projectexplorer/buildconfiguration.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libs/utils/algorithm.h b/src/libs/utils/algorithm.h
index e4de304743..a7ed90e15d 100644
--- a/src/libs/utils/algorithm.h
+++ b/src/libs/utils/algorithm.h
@@ -79,12 +79,12 @@ typename T::value_type findOr(const T &container, typename T::value_type other,
}
template<typename T, typename F>
-typename T::value_type maxElementOr(const T &container, typename T::value_type other, F function)
+typename T::value_type bestElementOr(const T &container, typename T::value_type other, F function)
{
typename T::const_iterator end = container.end();
typename T::const_iterator begin = container.begin();
- typename T::const_iterator it = std::max_element(begin, end, function);
+ typename T::const_iterator it = std::min_element(begin, end, function);
if (it == end)
return other;
return *it;
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp
index 2e16db3081..0b217f7cfe 100644
--- a/src/plugins/projectexplorer/buildconfiguration.cpp
+++ b/src/plugins/projectexplorer/buildconfiguration.cpp
@@ -345,7 +345,7 @@ IBuildConfigurationFactory *IBuildConfigurationFactory::find(Kit *k, const QStri
QList<IBuildConfigurationFactory *> factories
= ExtensionSystem::PluginManager::instance()->getObjects<IBuildConfigurationFactory>();
- return Utils::maxElementOr(factories, 0,
+ return Utils::bestElementOr(factories, 0,
[&k, &projectPath](IBuildConfigurationFactory *a, IBuildConfigurationFactory *b) {
return a->priority(k, projectPath) > b->priority(k, projectPath);
});
@@ -357,7 +357,7 @@ IBuildConfigurationFactory * IBuildConfigurationFactory::find(Target *parent)
QList<IBuildConfigurationFactory *> factories
= ExtensionSystem::PluginManager::getObjects<IBuildConfigurationFactory>();
- return Utils::maxElementOr(factories, 0,
+ return Utils::bestElementOr(factories, 0,
[&parent](IBuildConfigurationFactory *a, IBuildConfigurationFactory *b) {
return a->priority(parent) > b->priority(parent);
});