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);
|
QByteArray encodedProgramName = QFile::encodeName(program);
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// allow invoking of .app bundles on the Mac.
|
// allow invoking of .app bundles on the Mac.
|
||||||
QFileInfo fileInfo(QString::fromUtf8(encodedProgramName.constData()));
|
QFileInfo fileInfo(program);
|
||||||
if (encodedProgramName.endsWith(".app") && fileInfo.isDir()) {
|
if (encodedProgramName.endsWith(".app") && fileInfo.isDir()) {
|
||||||
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0,
|
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0,
|
||||||
QCFString(fileInfo.absoluteFilePath()),
|
QCFString(fileInfo.absoluteFilePath()),
|
||||||
@ -593,7 +593,7 @@ void QProcessPrivate::startProcess()
|
|||||||
}
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||||
encodedProgramName += "/Contents/MacOS/" + static_cast<QString>(str).toUtf8();
|
encodedProgramName += "/Contents/MacOS/" + QCFString::toQString(str).toUtf8();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -603,15 +603,8 @@ void QProcessPrivate::startProcess()
|
|||||||
argv[0] = dupProgramName;
|
argv[0] = dupProgramName;
|
||||||
|
|
||||||
// Add every argument to the list
|
// Add every argument to the list
|
||||||
for (int i = 0; i < arguments.count(); ++i) {
|
for (int i = 0; i < arguments.count(); ++i)
|
||||||
QString arg = arguments.at(i);
|
argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData());
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
// Duplicate the environment.
|
// Duplicate the environment.
|
||||||
int envc = 0;
|
int envc = 0;
|
||||||
@ -1375,13 +1368,8 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
|
|||||||
}
|
}
|
||||||
|
|
||||||
char **argv = new char *[arguments.size() + 2];
|
char **argv = new char *[arguments.size() + 2];
|
||||||
for (int i = 0; i < arguments.size(); ++i) {
|
for (int i = 0; i < arguments.size(); ++i)
|
||||||
#ifdef Q_OS_MAC
|
argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData());
|
||||||
argv[i + 1] = ::strdup(arguments.at(i).toUtf8().constData());
|
|
||||||
#else
|
|
||||||
argv[i + 1] = ::strdup(arguments.at(i).toLocal8Bit().constData());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
argv[arguments.size() + 1] = 0;
|
argv[arguments.size() + 1] = 0;
|
||||||
|
|
||||||
if (!program.contains(QLatin1Char('/'))) {
|
if (!program.contains(QLatin1Char('/'))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user