Commit 1fb5ffa0 authored by con's avatar con
Browse files

Fixes: Wizard page that allows adding to pro file selected non-optimal file

The heuristics depended on pro files appearing before pri files in the
list, but now the list is alphabetically sorted.
Leading to deployment.pri being selected by default for mobile projects.

Task-number: QTCREATORBUG-2792
Reviewed-by: Friedemann Kleint
parent 5ac981a0
......@@ -200,7 +200,6 @@ static QList<ProjectEntry> findDeployProject(const QList<ProjectEntry> &projects
// path. Either a direct match on the directory or the directory with
// the longest matching path (list containing"/project/subproject1" matching
// common path "/project/subproject1/newuserpath").
// This relies on 'pro' occurring before 'pri' in the list.
static int findMatchingProject(const QList<ProjectEntry> &projects,
const QString &commonPath)
......@@ -209,14 +208,20 @@ static int findMatchingProject(const QList<ProjectEntry> &projects,
int bestMatch = -1;
int bestMatchLength = 0;
bool bestMatchIsProFile = false;
const int count = projects.size();
for (int p = 0; p < count; p++) {
// Direct match or better match? (note that the wizards' files are native).
const QString &projectDirectory =;
if (projectDirectory == commonPath)
return p;
if (projectDirectory.size() > bestMatchLength
const ProjectEntry &entry =;
const QString &projectDirectory =;
const int projectDirectorySize = projectDirectory.size();
if (projectDirectorySize == bestMatchLength && bestMatchIsProFile)
continue; // prefer first pro file over all other files with same bestMatchLength
if (projectDirectorySize == bestMatchLength && entry.type == ProjectEntry::PriFile)
continue; // we already have a match with same bestMatchLength that is at least a pri file
if (projectDirectorySize >= bestMatchLength
&& commonPath.startsWith(projectDirectory)) {
bestMatchIsProFile = (entry.type == ProjectEntry::ProFile);
bestMatchLength = projectDirectory.size();
bestMatch = p;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment