Commit 13cc8db2 authored by Eike Ziller's avatar Eike Ziller

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/1698Reviewed-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
......@@ -98,36 +98,55 @@ void FileInProjectFinder::setProjectFiles(const QStringList &projectFiles)
QString FileInProjectFinder::findFile(const QString &originalPath, bool *success) const
{
if (!m_projectDir.isEmpty()) {
int prefixToIgnore = -1;
const QChar separator = QLatin1Char('/');
if (originalPath.startsWith(m_projectDir + separator)) {
if (success)
*success = true;
return originalPath;
#ifdef Q_OS_MAC
// starting with the project path is not sufficient if the file was
// 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 (success)
*success = true;
return m_cache.value(originalPath);
// check if cached path is still there
QString candidate = 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,
// and see if the new relative path exists in the build directory.
if (originalPath.contains(separator)) {
for (int pos = originalPath.indexOf(separator); pos != -1;
pos = originalPath.indexOf(separator, pos + 1)) {
QString candidate = originalPath;
candidate.remove(0, pos);
candidate.prepend(m_projectDir);
QFileInfo candidateInfo(candidate);
if (candidateInfo.exists() && candidateInfo.isFile()) {
if (success)
*success = true;
m_cache.insert(originalPath, candidate);
return candidate;
}
if (prefixToIgnore < 0)
prefixToIgnore = originalPath.indexOf(separator);
while (prefixToIgnore != -1) {
QString candidate = originalPath;
candidate.remove(0, prefixToIgnore);
candidate.prepend(m_projectDir);
QFileInfo candidateInfo(candidate);
if (candidateInfo.exists() && candidateInfo.isFile()) {
if (success)
*success = true;
m_cache.insert(originalPath, candidate);
return candidate;
}
prefixToIgnore = originalPath.indexOf(separator, prefixToIgnore + 1);
}
}
......
Markdown is supported
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