diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 9027950cea4829b83c548506a7e86a10e8305432..52147a75bcaa6d24dc1760e982ccb8d707c210f6 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 6b6c52411f1c0c6dadfaf45b51e64c132e971af0..26d2f08c89ff904e317fef570da969ea93dbc4e9 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 5ec3355659c06ad9d5cfbe65237cd49ae511df12..4c54838b6f133e54d406f7acd77f9d508d0b5e35 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 20808d95ab3d1580965f9b2755ed9b61843b6b0c..a11fc013e2a92d4124b48df6f5dc935844e852d7 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);