normalize the process arguments to Normalization Form D on mac
QFile::encodeName() does this for us + simplifies the code a bit Change-Id: Id2ca2615e20408229dd021c26587fefd60365352 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
b24bf21fcb
commit
9b0aa9dc4c
@ -578,7 +578,7 @@ void QProcessPrivate::startProcess()
|
||||
QByteArray encodedProgramName = QFile::encodeName(program);
|
||||
#ifdef Q_OS_MAC
|
||||
// allow invoking of .app bundles on the Mac.
|
||||
QFileInfo fileInfo(QString::fromUtf8(encodedProgramName.constData()));
|
||||
QFileInfo fileInfo(program);
|
||||
if (encodedProgramName.endsWith(".app") && fileInfo.isDir()) {
|
||||
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0,
|
||||
QCFString(fileInfo.absoluteFilePath()),
|
||||
@ -593,7 +593,7 @@ void QProcessPrivate::startProcess()
|
||||
}
|
||||
if (url) {
|
||||
QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||
encodedProgramName += "/Contents/MacOS/" + static_cast<QString>(str).toUtf8();
|
||||
encodedProgramName += "/Contents/MacOS/" + QCFString::toQString(str).toUtf8();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -603,15 +603,8 @@ void QProcessPrivate::startProcess()
|
||||
argv[0] = dupProgramName;
|
||||
|
||||
// Add every argument to the list
|
||||
for (int i = 0; i < arguments.count(); ++i) {
|
||||
QString arg = arguments.at(i);
|
||||
#ifdef Q_OS_MAC
|
||||
// Mac OS X uses UTF8 for exec, regardless of the system locale.
|
||||
argv[i + 1] = ::strdup(arg.toUtf8().constData());
|
||||
#else
|
||||
argv[i + 1] = ::strdup(arg.toLocal8Bit().constData());
|
||||
#endif
|
||||
}
|
||||
for (int i = 0; i < arguments.count(); ++i)
|
||||
argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData());
|
||||
|
||||
// Duplicate the environment.
|
||||
int envc = 0;
|
||||
@ -1375,13 +1368,8 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
|
||||
}
|
||||
|
||||
char **argv = new char *[arguments.size() + 2];
|
||||
for (int i = 0; i < arguments.size(); ++i) {
|
||||
#ifdef Q_OS_MAC
|
||||
argv[i + 1] = ::strdup(arguments.at(i).toUtf8().constData());
|
||||
#else
|
||||
argv[i + 1] = ::strdup(arguments.at(i).toLocal8Bit().constData());
|
||||
#endif
|
||||
}
|
||||
for (int i = 0; i < arguments.size(); ++i)
|
||||
argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData());
|
||||
argv[arguments.size() + 1] = 0;
|
||||
|
||||
if (!program.contains(QLatin1Char('/'))) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user