QProcessPrivate::startProcess - fix invalid encodedProgramName (OS X)
CFBundleCopyExecutableURL returns different URLs (can be absolute or relative) for the same bundle (caching) - and this results in an invalid encodedProgramName (in case we try to start the same process twice), for example, if we start: QProcess p; p.start("nestedDir/nested.app") twice, the second time we'll have an error trying to start something like nestedDir/nested.app/_and_here_absolute_url. Change-Id: I8ac42e20fe3b9fe8b80d5b5c663672e77d88269d Task-number: QTBUG-49837 Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
This commit is contained in:
parent
bf4b281099
commit
7d2c87311e
@ -92,6 +92,7 @@ QT_END_NAMESPACE
|
|||||||
#include <private/qthread_p.h>
|
#include <private/qthread_p.h>
|
||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
|
#include <qdir.h>
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
#include <qmutex.h>
|
#include <qmutex.h>
|
||||||
#include <qsemaphore.h>
|
#include <qsemaphore.h>
|
||||||
@ -362,11 +363,14 @@ void QProcessPrivate::startProcess()
|
|||||||
static QBasicMutex cfbundleMutex;
|
static QBasicMutex cfbundleMutex;
|
||||||
QMutexLocker lock(&cfbundleMutex);
|
QMutexLocker lock(&cfbundleMutex);
|
||||||
QCFType<CFBundleRef> bundle = CFBundleCreate(0, url);
|
QCFType<CFBundleRef> bundle = CFBundleCreate(0, url);
|
||||||
url = CFBundleCopyExecutableURL(bundle);
|
// 'executableURL' can be either relative or absolute ...
|
||||||
|
QCFType<CFURLRef> executableURL = CFBundleCopyExecutableURL(bundle);
|
||||||
|
// not to depend on caching - make sure it's always absolute.
|
||||||
|
url = CFURLCopyAbsoluteURL(executableURL);
|
||||||
}
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
const QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||||
encodedProgramName += "/Contents/MacOS/" + QCFString::toQString(str).toUtf8();
|
encodedProgramName += (QDir::separator() + QDir(program).relativeFilePath(QCFString::toQString(str))).toUtf8();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user