From fa79add2938cea0b3406e3d1d288a4b77288713f Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 2 Jun 2010 15:07:27 +0200 Subject: [PATCH] QmlJS: Check for existance of qmldump binary before using it. --- src/libs/qmljs/qmljsinterpreter.cpp | 24 ++++++++++++++++++++++-- src/libs/qmljs/qmljsinterpreter.h | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 535e4eebe7d..39bc441bda9 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -1933,6 +1933,24 @@ const Value *Function::invoke(const Activation *activation) const // typing environment //////////////////////////////////////////////////////////////////////////////// +CppQmlTypesLoader::CppQmlTypesLoader() +{ + QDir qmldumpExecutable(QCoreApplication::applicationDirPath()); +#ifndef Q_OS_WIN + m_qmldumpPath = qmldumpExecutable.absoluteFilePath(QLatin1String("qmldump")); +#else + m_qmldumpPath = qmldumpExecutable.absoluteFilePath(QLatin1String("qmldump.exe")); +#endif + QFileInfo qmldumpFileInfo(m_qmldumpPath); + if (!qmldumpFileInfo.exists()) { + qWarning() << "QmlJS::Interpreter::CppQmlTypesLoader: qmldump executable does not exist at" << m_qmldumpPath; + m_qmldumpPath.clear(); + } else if (!qmldumpFileInfo.isFile()) { + qWarning() << "QmlJS::Interpreter::CppQmlTypesLoader: " << m_qmldumpPath << " is not a file"; + m_qmldumpPath.clear(); + } +} + CppQmlTypesLoader *CppQmlTypesLoader::instance() { static CppQmlTypesLoader _instance; @@ -1966,10 +1984,12 @@ QStringList CppQmlTypesLoader::load(const QFileInfoList &xmlFiles) void CppQmlTypesLoader::loadPluginTypes(const QString &pluginPath) { + if (m_qmldumpPath.isEmpty()) + return; + QProcess *process = new QProcess(this); connect(process, SIGNAL(finished(int)), SLOT(processDone(int))); - QDir qmldumpExecutable(QCoreApplication::applicationDirPath()); - process->start(qmldumpExecutable.filePath("qmldump"), QStringList(pluginPath)); + process->start(m_qmldumpPath, QStringList(pluginPath)); } void CppQmlTypesLoader::processDone(int exitCode) diff --git a/src/libs/qmljs/qmljsinterpreter.h b/src/libs/qmljs/qmljsinterpreter.h index 69ad2427a81..ffa53b869ef 100644 --- a/src/libs/qmljs/qmljsinterpreter.h +++ b/src/libs/qmljs/qmljsinterpreter.h @@ -516,6 +516,7 @@ class QMLJS_EXPORT CppQmlTypesLoader : public QObject { Q_OBJECT public: + CppQmlTypesLoader(); static CppQmlTypesLoader *instance(); QHash objects; @@ -530,6 +531,7 @@ private slots: private: void addObjects(QMap &newObjects); + QString m_qmldumpPath; }; class QMLJS_EXPORT CppQmlTypes