From 3a110439e930c14aeebc7671c0fbce5321f4695e Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 21 Sep 2011 15:54:07 +0200 Subject: [PATCH] QmlJS: Only try qmldump on Desktop and Simulator Qt. In particular, don't complain about a missing qmldump binary on other platforms. Change-Id: Ie2e96bcb67e609aa5aed31510b06139d2d9ce77e Reviewed-on: http://codereview.qt-project.org/5327 Reviewed-by: Qt Sanity Bot Reviewed-by: Leandro T. C. Melo --- src/libs/qmljs/qmljsmodelmanagerinterface.h | 5 +++ src/plugins/qmljstools/qmljsplugindumper.cpp | 37 ++++++++++++-------- src/plugins/qt4projectmanager/qt4project.cpp | 20 ++++++++--- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index 5f3c5e30b89..316c6d52cf3 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -61,6 +61,7 @@ public: { public: ProjectInfo() + : tryQmlDump(false) { } ProjectInfo(QPointer project) @@ -80,8 +81,12 @@ public: QPointer project; QStringList sourceFiles; QStringList importPaths; + + // whether trying to run qmldump makes sense + bool tryQmlDump; QString qmlDumpPath; Utils::Environment qmlDumpEnvironment; + QString qtImportsPath; QString qtVersionString; }; diff --git a/src/plugins/qmljstools/qmljsplugindumper.cpp b/src/plugins/qmljstools/qmljsplugindumper.cpp index 3983033682b..8d10e930c11 100644 --- a/src/plugins/qmljstools/qmljsplugindumper.cpp +++ b/src/plugins/qmljstools/qmljsplugindumper.cpp @@ -220,31 +220,34 @@ void PluginDumper::dumpAllPlugins() } } -static QString qmldumpErrorPreamble() +static QString noTypeinfoError(const QString &libraryPath) { - return PluginDumper::tr("QML module does not contain information about components contained in plugins.\n" - "See \"Using QML Modules with Plugins\" in the documentation.") + QLatin1String("\n\n"); + return PluginDumper::tr("QML module at:\n" + "%1\n" + "does not contain information about components contained in plugins.\n" + "See \"Using QML Modules with Plugins\" in the documentation.").arg( + libraryPath); } static QString qmldumpErrorMessage(const QString &libraryPath, const QString &error) { - return qmldumpErrorPreamble() + - PluginDumper::tr("Automatic type dump of QML module in %1 failed.\nErrors:\n%2\n"). - arg(libraryPath, error); + return noTypeinfoError(libraryPath) + QLatin1String("\n\n") + + PluginDumper::tr("Automatic type dump of QML module failed.\nErrors:\n%1\n"). + arg(error); } static QString qmldumpFailedMessage(const QString &libraryPath, const QString &error) { QString firstLines = QStringList(error.split(QLatin1Char('\n')).mid(0, 10)).join(QLatin1String("\n")); - return qmldumpErrorPreamble() + - PluginDumper::tr("Automatic type dump of QML module in %1 failed.\n" + return noTypeinfoError(libraryPath) + QLatin1String("\n\n") + + PluginDumper::tr("Automatic type dump of QML module failed.\n" "First 10 lines or errors:\n" "\n" - "%2" + "%1" "\n" "Check 'General Messages' output pane for details." - ).arg(libraryPath, firstLines); + ).arg(firstLines); } static void printParseWarnings(const QString &libraryPath, const QString &warning) @@ -400,16 +403,22 @@ void PluginDumper::dump(const Plugin &plugin) ModelManagerInterface::ProjectInfo info = m_modelManager->projectInfo(activeProject); - if (info.qmlDumpPath.isEmpty()) { + if (!info.tryQmlDump || info.qmlDumpPath.isEmpty()) { const Snapshot snapshot = m_modelManager->snapshot(); LibraryInfo libraryInfo = snapshot.libraryInfo(plugin.qmldirPath); if (!libraryInfo.isValid()) return; - libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, - qmldumpErrorMessage(plugin.qmldirPath, + QString errorMessage; + if (!info.tryQmlDump) { + errorMessage = noTypeinfoError(plugin.qmldirPath); + } else { + errorMessage = qmldumpErrorMessage(plugin.qmldirPath, tr("Could not locate the helper application for dumping type information from C++ plugins.\n" - "Please build the qmldump applcation on the Qt version options page."))); + "Please build the qmldump applcation on the Qt version options page.")); + } + + libraryInfo.setPluginTypeInfoStatus(LibraryInfo::DumpError, errorMessage); m_modelManager->updateLibraryInfo(plugin.qmldirPath, libraryInfo); return; } diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 91fc60c3c38..1d06522bb1f 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -615,23 +616,34 @@ void Qt4Project::updateQmlJSCodeModel() foreach (Qt4ProFileNode *node, proFiles) { projectInfo.importPaths.append(node->variableValue(QmlImportPathVar)); } + bool preferDebugDump = false; + projectInfo.tryQmlDump = false; if (activeTarget() && activeTarget()->activeBuildConfiguration()) { preferDebugDump = activeTarget()->activeQt4BuildConfiguration()->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild; QtSupport::BaseQtVersion *qtVersion = activeTarget()->activeQt4BuildConfiguration()->qtVersion(); if (qtVersion && qtVersion->isValid()) { + projectInfo.tryQmlDump = qtVersion->type() == QtSupport::Constants::DESKTOPQT + || qtVersion->type() == QtSupport::Constants::SIMULATORQT; projectInfo.qtImportsPath = qtVersion->versionInfo().value("QT_INSTALL_IMPORTS"); if (!projectInfo.qtImportsPath.isEmpty()) projectInfo.importPaths += projectInfo.qtImportsPath; projectInfo.qtVersionString = qtVersion->qtVersionString(); } - } - const Qt4BuildConfiguration *bc = activeTarget()->activeQt4BuildConfiguration(); - QtSupport::QmlDumpTool::pathAndEnvironment(this, bc->qtVersion(), bc->toolChain(), - preferDebugDump, &projectInfo.qmlDumpPath, &projectInfo.qmlDumpEnvironment); projectInfo.importPaths.removeDuplicates(); + if (projectInfo.tryQmlDump) { + const Qt4BuildConfiguration *bc = activeTarget()->activeQt4BuildConfiguration(); + if (bc) { + QtSupport::QmlDumpTool::pathAndEnvironment(this, bc->qtVersion(), bc->toolChain(), + preferDebugDump, &projectInfo.qmlDumpPath, &projectInfo.qmlDumpEnvironment); + } + } else { + projectInfo.qmlDumpPath.clear(); + projectInfo.qmlDumpEnvironment.clear(); + } + modelManager->updateProjectInfo(projectInfo); }