From b87f0bfdcfbf875cd443cdd72899cc649c5a7ff4 Mon Sep 17 00:00:00 2001 From: Christian Kamm <christian.d.kamm@nokia.com> Date: Wed, 29 Sep 2010 17:54:06 +0200 Subject: [PATCH] QmlJS: Fix qmldump not working for qmlproject projects. Reviewed-by: Erik Verbruggen --- src/plugins/qmlprojectmanager/qmlproject.cpp | 6 ++++ src/plugins/qt4projectmanager/qmldumptool.cpp | 35 +++++++++++++++++++ src/plugins/qt4projectmanager/qmldumptool.h | 2 ++ src/plugins/qt4projectmanager/qt4project.cpp | 28 +-------------- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 9027950cea4..52147a75bca 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -37,6 +37,7 @@ #include <coreplugin/messagemanager.h> #include <extensionsystem/pluginmanager.h> #include <projectexplorer/filewatcher.h> +#include <qt4projectmanager/qmldumptool.h> #include <qmljs/qmljsmodelmanagerinterface.h> #include <QTextStream> @@ -129,6 +130,11 @@ void QmlProject::refresh(RefreshOptions options) QmlJS::ModelManagerInterface::ProjectInfo pinfo(this); pinfo.sourceFiles = files(); pinfo.importPaths = importPaths(); + + if (pinfo.qmlDumpPath.isNull()) { + pinfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpPath(); + } + m_modelManager->updateProjectInfo(pinfo); } diff --git a/src/plugins/qt4projectmanager/qmldumptool.cpp b/src/plugins/qt4projectmanager/qmldumptool.cpp index 6b6c52411f1..26d2f08c89f 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.cpp +++ b/src/plugins/qt4projectmanager/qmldumptool.cpp @@ -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 diff --git a/src/plugins/qt4projectmanager/qmldumptool.h b/src/plugins/qt4projectmanager/qmldumptool.h index 5ec3355659c..4c54838b6f1 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.h +++ b/src/plugins/qt4projectmanager/qmldumptool.h @@ -59,6 +59,8 @@ public: // Copy the source files to a target location and return the chosen target location. static QString copy(const QString &qtInstallData, QString *errorMessage); + static QString qmlDumpPath(); + private: static QStringList installDirectories(const QString &qtInstallData); diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 20808d95ab3..a11fc013e2a 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -586,34 +586,8 @@ void Qt4Project::updateQmlJSCodeModel() } projectInfo.importPaths.removeDuplicates(); - if (projectInfo.qmlDumpPath.isNull()) { - ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); - projectInfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::toolForProject(activeProject); - - // ### this is needed for qmlproject and cmake project support, but may not work in all cases. - if (projectInfo.qmlDumpPath.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"); - projectInfo.qmlDumpPath = QmlDumpTool::toolByInstallData(qtInstallData); - - if (!projectInfo.qmlDumpPath.isEmpty()) { - break; - } - } - } - } - QFileInfo qmldumpFileInfo(projectInfo.qmlDumpPath); - if (!qmldumpFileInfo.exists()) { - qWarning() << "Qt4Project::loadQmlPluginTypes: qmldump executable does not exist at" << projectInfo.qmlDumpPath; - projectInfo.qmlDumpPath.clear(); - } else if (!qmldumpFileInfo.isFile()) { - qWarning() << "Qt4Project::loadQmlPluginTypes: " << projectInfo.qmlDumpPath << " is not a file"; - projectInfo.qmlDumpPath.clear(); - } + projectInfo.qmlDumpPath = QmlDumpTool::qmlDumpPath(); } modelManager->updateProjectInfo(projectInfo); -- GitLab