diff options
author | kh1 <karsten.heimrich@digia.com> | 2014-04-03 15:02:00 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2014-04-04 11:09:07 +0200 |
commit | ea25dca5eae415c2a555865efe7176b07f7bf109 (patch) | |
tree | 36aa9a7cdd58bcc1564184d1ca101c0d25934224 /tools | |
parent | 09c3bf53a53368642780b63de64cb8cfe73f0e17 (diff) |
Fix strange error message.
Task-number: QTIFW-309
If a component script file is empty or misses the component class
constructor, bail out during binary create or installer execution.
Change-Id: I422c64186652a52122d54b5b042139803c24ba10
Reviewed-by: Niels Weber <niels.weber@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/common/repositorygen.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index 77ce8eb6f..11063e789 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -293,13 +293,19 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met // copy script file const QString script = package.firstChildElement(QLatin1String("Script")).text(); if (!script.isEmpty()) { - QString scriptContent; QFile scriptFile(QString::fromLatin1("%1/meta/%2").arg(info.directory, script)); - if (scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(&scriptFile); - scriptContent = in.readAll(); + if (!scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + throw QInstaller::Error(QString::fromLatin1("Could not open component script: '%1'") + .arg(scriptFile.fileName())); } + QString scriptContent = QString::fromLatin1( + "(function() {" + " %1;" + " if (typeof Component == \"undefined\")" + " throw \"Missing Component constructor. Please check your script.\";" + "})();").arg(QTextStream(&scriptFile).readAll()); + // if the user isn't aware of the downloadable archives value we will add it automatically later foundDownloadableArchives |= scriptContent.contains(QLatin1String("addDownloadableArchive")) || scriptContent.contains(QLatin1String("removeDownloadableArchive")); @@ -307,8 +313,9 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met static QScriptEngine testScriptEngine; testScriptEngine.evaluate(scriptContent, scriptFile.fileName()); if (testScriptEngine.hasUncaughtException()) { - throw QInstaller::Error(QString::fromLatin1("Exception while loading component script: '%1'") - .arg(QInstaller::uncaughtExceptionString(&testScriptEngine, scriptFile.fileName()))); + throw QInstaller::Error(QString::fromLatin1("Exception while loading component " + "script: '%1'").arg(QInstaller::uncaughtExceptionString(&testScriptEngine, + scriptFile.fileName()))); } // add RequiresAdminRights tag to xml if addElevatedOperation is used somewhere |