logic: Fixed detected global search paths keep original order

The global header search paths were sorted alphabetically after detection due to checking for uniqueness. This caused
problems with #include_next directives in certain std header files that relied on the correct header search path order.

bug id = 101
This commit is contained in:
Eberhard Graether
2016-06-24 13:35:16 +02:00
parent 44cee3d130
commit 140d4a406a
2 changed files with 27 additions and 6 deletions
+26
View File
@@ -34,6 +34,9 @@ namespace utility
template<typename T>
void append(std::unordered_set<T>& a, const std::unordered_set<T>& b);
template<typename T>
std::vector<T> unique(const std::vector<T>& a);
template<typename T>
std::vector<T> toVector(const std::deque<T>& d);
@@ -86,6 +89,29 @@ void utility::append(std::unordered_set<T>& a, const std::unordered_set<T>& b)
a.insert(b.begin(), b.end());
}
template<typename T>
std::vector<T> utility::unique(const std::vector<T>& a)
{
std::map<T, size_t> unique;
size_t i = 0;
for (const T& t : a)
{
if (unique.emplace(t, i).second)
{
i++;
}
}
std::vector<T> r(i, T());
for (const std::pair<T, size_t>& p : unique)
{
r[p.second] = p.first;
}
return r;
}
template<typename T>
std::vector<T> utility::toVector(const std::deque<T>& d)
{
@@ -191,12 +191,7 @@ void QtProjectWizzardContentPaths::detectionClicked()
}
std::vector<FilePath> oldPaths = m_list->getList();
std::set<FilePath> uniquePaths;
uniquePaths.insert(oldPaths.begin(), oldPaths.end());
uniquePaths.insert(paths.begin(), paths.end());
m_list->setList(utility::toVector(uniquePaths));
m_list->setList(utility::unique(utility::concat(oldPaths, paths)));
}