QmlJS: Fix qmldump not working for qmlproject projects.

Reviewed-by: Erik Verbruggen
This commit is contained in:
Christian Kamm
2010-09-29 17:54:06 +02:00
parent f5b4668fa5
commit b87f0bfdcf
4 changed files with 44 additions and 27 deletions

View File

@@ -33,6 +33,7 @@
#include <coreplugin/icore.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <QDesktopServices>
#include <QCoreApplication>
#include <QDir>
@@ -139,4 +140,38 @@ QStringList QmlDumpTool::installDirectories(const QString &qtInstallData)
return directories;
}
QString QmlDumpTool::qmlDumpPath()
{
QString path;
ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
path = Qt4ProjectManager::QmlDumpTool::toolForProject(activeProject);
// ### this is needed for qmlproject and cmake project support, but may not work in all cases.
if (path.isEmpty()) {
// Try to locate default path in Qt Versions
QtVersionManager *qtVersions = QtVersionManager::instance();
foreach (QtVersion *version, qtVersions->validVersions()) {
if (version->supportsTargetId(Constants::DESKTOP_TARGET_ID)) {
const QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA");
path = QmlDumpTool::toolByInstallData(qtInstallData);
if (!path.isEmpty()) {
break;
}
}
}
}
QFileInfo qmldumpFileInfo(path);
if (!qmldumpFileInfo.exists()) {
qWarning() << "QmlDumpTool::qmlDumpPath: qmldump executable does not exist at" << path;
path.clear();
} else if (!qmldumpFileInfo.isFile()) {
qWarning() << "QmlDumpTool::qmlDumpPath: " << path << " is not a file";
path.clear();
}
return path;
}
} // namespace