Commit e414335f authored by Kai Koehne's avatar Kai Koehne

Fix capitalization problems with qmlviewer

qmlviewer is picky about file path capitalization, and will bail out with
'File name case mismatch' if e.g. the working directory is wrongly
capitalized. Prevent this by computing the canonical path of
the qml file + working directory in advance.

Reviewed-by: Alessandro Portale
Task-number: QTCREATORBUG-3417
parent 550a85a4
......@@ -45,6 +45,10 @@
#include <qt4projectmanager/qtoutputformatter.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#ifdef Q_OS_WIN32
#include <Windows.h>
#endif
using Core::EditorManager;
using Core::ICore;
using Core::IEditor;
......@@ -144,16 +148,18 @@ QString QmlProjectRunConfiguration::viewerArguments() const
Utils::QtcProcess::addArg(&args, importPath);
}
const QString &s = mainScript();
if (!s.isEmpty())
QString s = mainScript();
if (!s.isEmpty()) {
s = canonicalCapsPath(s);
Utils::QtcProcess::addArg(&args, s);
}
return args;
}
QString QmlProjectRunConfiguration::workingDirectory() const
{
QFileInfo projectFile(qmlTarget()->qmlProject()->file()->fileName());
return projectFile.absolutePath();
return canonicalCapsPath(projectFile.absolutePath());
}
int QmlProjectRunConfiguration::qtVersionId() const
......@@ -172,6 +178,32 @@ void QmlProjectRunConfiguration::setQtVersionId(int id)
m_configurationWidget.data()->updateQtVersionComboBox();
}
/* QtDeclarative checks explicitly that the capitalization for any URL / path
is exactly like the capitalization on disk. This method is uses the same
native Windows API's to get the exact canonical path. */
QString QmlProjectRunConfiguration::canonicalCapsPath(const QString &fileName)
{
QString canonicalPath = QFileInfo(fileName).canonicalFilePath();
#if defined(Q_OS_WIN32)
wchar_t *buffer = 0;
do {
long length = ::GetLongPathName((wchar_t*)fileName.utf16(), NULL, 0);
if (!length)
break;
buffer = new wchar_t[length];
DWORD rv = ::GetLongPathName((wchar_t*)fileName.utf16(), buffer, length);
if (!rv)
break;
canonicalPath = QString((QChar*)buffer);
} while (false);
delete buffer;
#endif
return canonicalPath;
}
Qt4ProjectManager::QtVersion *QmlProjectRunConfiguration::qtVersion() const
{
if (m_qtVersionId == -1)
......
......@@ -120,6 +120,8 @@ private:
void ctor();
static bool isValidVersion(Qt4ProjectManager::QtVersion *version);
void setQtVersionId(int id);
static QString canonicalCapsPath(const QString &filePath);
Utils::Environment baseEnvironment() const;
void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
......
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