Skip to content
Snippets Groups Projects
Commit 13cc8db2 authored by Eike Ziller's avatar Eike Ziller
Browse files

Don't jump to the wrong qml file in insource build.

Doing an insource build on Mac will copy the qml file(s) into the
applications resources folder, which still is located under the project
root. In that case it was assumed to be the original file. The patch
assumes that for files in the project root with
".app/Contents/Resources" in the path will need the magic to happen.

Change-Id: I25ffea8a1be7caff5313d03590b4094cb3429492
Reviewed-on: http://codereview.qt.nokia.com/1698


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@nokia.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 269a7d6f
No related branches found
No related tags found
No related merge requests found
...@@ -98,36 +98,55 @@ void FileInProjectFinder::setProjectFiles(const QStringList &projectFiles) ...@@ -98,36 +98,55 @@ void FileInProjectFinder::setProjectFiles(const QStringList &projectFiles)
QString FileInProjectFinder::findFile(const QString &originalPath, bool *success) const QString FileInProjectFinder::findFile(const QString &originalPath, bool *success) const
{ {
if (!m_projectDir.isEmpty()) { if (!m_projectDir.isEmpty()) {
int prefixToIgnore = -1;
const QChar separator = QLatin1Char('/'); const QChar separator = QLatin1Char('/');
if (originalPath.startsWith(m_projectDir + separator)) { if (originalPath.startsWith(m_projectDir + separator)) {
if (success) #ifdef Q_OS_MAC
*success = true; // starting with the project path is not sufficient if the file was
return originalPath; // copied in an insource build, e.g. into MyApp.app/Contents/Resources
static const QString appResourcePath = QString::fromLatin1(".app/Contents/Resources");
if (originalPath.contains(appResourcePath)) {
// the path is inside the project, but most probably as a resource of an insource build
// so ignore that path
prefixToIgnore = originalPath.indexOf(appResourcePath) + appResourcePath.length();
} else {
#endif
if (success)
*success = true;
return originalPath;
#ifdef Q_OS_MAC
}
#endif
} }
if (m_cache.contains(originalPath)) { if (m_cache.contains(originalPath)) {
if (success) // check if cached path is still there
*success = true; QString candidate = m_cache.value(originalPath);
return m_cache.value(originalPath); QFileInfo candidateInfo(candidate);
if (candidateInfo.exists() && candidateInfo.isFile()) {
if (success)
*success = true;
return candidate;
}
} }
// Strip directories one by one from the beginning of the path, // Strip directories one by one from the beginning of the path,
// and see if the new relative path exists in the build directory. // and see if the new relative path exists in the build directory.
if (originalPath.contains(separator)) { if (prefixToIgnore < 0)
for (int pos = originalPath.indexOf(separator); pos != -1; prefixToIgnore = originalPath.indexOf(separator);
pos = originalPath.indexOf(separator, pos + 1)) { while (prefixToIgnore != -1) {
QString candidate = originalPath; QString candidate = originalPath;
candidate.remove(0, pos); candidate.remove(0, prefixToIgnore);
candidate.prepend(m_projectDir); candidate.prepend(m_projectDir);
QFileInfo candidateInfo(candidate); QFileInfo candidateInfo(candidate);
if (candidateInfo.exists() && candidateInfo.isFile()) { if (candidateInfo.exists() && candidateInfo.isFile()) {
if (success) if (success)
*success = true; *success = true;
m_cache.insert(originalPath, candidate); m_cache.insert(originalPath, candidate);
return candidate; return candidate;
}
} }
prefixToIgnore = originalPath.indexOf(separator, prefixToIgnore + 1);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment