From 55e31e6389c78218f1f9039a4bf642db68a86975 Mon Sep 17 00:00:00 2001 From: Dmitry Sokolov Date: Thu, 14 Feb 2019 11:12:18 +0100 Subject: Kludge popen/pclose calls on MS-Win For MS Visual Studio we need to use _popen() and _pclose() instead of the POSIX functions; and the pipe needs to be opened in binary mode. Change-Id: Ide0fb26a1e5f121b384b0baaf8100f26c614ccc6 Fixes: QTBUG-73810 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/tools/androiddeployqt/main.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/tools') diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 712a8091fb..b0df833b87 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -43,6 +43,15 @@ #include #include + +#ifdef Q_CC_MSVC +#define popen _popen +#define QT_POPEN_READ "rb" +#define pclose _pclose +#else +#define QT_POPEN_READ "r" +#endif + static const bool mustReadOutputAnyway = true; // pclose seems to return the wrong error code unless we read the output void deleteRecursively(const QString &dirName) @@ -70,7 +79,7 @@ FILE *openProcess(const QString &command) QString processedCommand = command; #endif - return popen(processedCommand.toLocal8Bit().constData(), "r"); + return popen(processedCommand.toLocal8Bit().constData(), QT_POPEN_READ); } struct QtDependency @@ -1721,7 +1730,7 @@ bool scanImports(Options *options, QSet *usedDependencies) .arg(shellQuote(rootPath)) .arg(importPaths.join(QLatin1Char(' '))); - FILE *qmlImportScannerCommand = popen(qmlImportScanner.toLocal8Bit().constData(), "r"); + FILE *qmlImportScannerCommand = popen(qmlImportScanner.toLocal8Bit().constData(), QT_POPEN_READ); if (qmlImportScannerCommand == 0) { fprintf(stderr, "Couldn't run qmlimportscanner.\n"); return false; @@ -2160,7 +2169,7 @@ bool createAndroidProject(const Options &options) if (options.verbose) fprintf(stdout, " -- Command: %s\n", qPrintable(androidTool)); - FILE *androidToolCommand = popen(androidTool.toLocal8Bit().constData(), "r"); + FILE *androidToolCommand = popen(androidTool.toLocal8Bit().constData(), QT_POPEN_READ); if (androidToolCommand == 0) { fprintf(stderr, "Cannot run command '%s'\n", qPrintable(androidTool)); return false; -- cgit v1.2.3