Fix moc-crash when compiling QtScript on Windows.

@file-arguments were not parsed correctly.

Change-Id: I10dc7ebcd7c9eedb332c7c350aa06c7ac9c2e8b1
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
bb10
Friedemann Kleint 2013-09-11 14:55:19 +02:00 committed by The Qt Project
parent 546d52e605
commit ba7da9b733
1 changed files with 7 additions and 8 deletions

View File

@ -152,12 +152,12 @@ QByteArray composePreprocessorOutput(const Symbols &symbols) {
static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments) static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments)
{ {
QStringList allArguments = arguments; QStringList allArguments;
int n = 0; allArguments.reserve(arguments.size());
while (n < allArguments.count()) { foreach (const QString &argument, arguments) {
// "@file" doesn't start with a '-' so we can't use QCommandLineParser for it // "@file" doesn't start with a '-' so we can't use QCommandLineParser for it
if (arguments.at(n).startsWith(QLatin1Char('@'))) { if (argument.startsWith(QLatin1Char('@'))) {
QString optionsFile = arguments.at(n); QString optionsFile = argument;
optionsFile.remove(0, 1); optionsFile.remove(0, 1);
if (optionsFile.isEmpty()) { if (optionsFile.isEmpty()) {
error("The @ option requires an input file"); error("The @ option requires an input file");
@ -168,14 +168,13 @@ static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments)
error("Cannot open options file specified with @"); error("Cannot open options file specified with @");
return QStringList(); return QStringList();
} }
allArguments.removeAt(n);
while (!f.atEnd()) { while (!f.atEnd()) {
QString line = QString::fromLocal8Bit(f.readLine().trimmed()); QString line = QString::fromLocal8Bit(f.readLine().trimmed());
if (!line.isEmpty()) if (!line.isEmpty())
allArguments.insert(n++, line); allArguments << line;
} }
} else { } else {
++n; allArguments << argument;
} }
} }
return allArguments; return allArguments;