From bb0263eb80620b64057b6a0a1d6bccad3d3e6282 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 15 Jul 2014 15:14:52 +0200 Subject: rcc: Prevent CRLF conversion on Windows for -binary Fix an issue on Windows where rcc -binary project.qrc >project.rcc resulted in a corrupted file (\n was automatically replaced with \r\n). This is caused by Qt using fwrite internally, which will automatically replace linefeed with carriage-return for streams opened in text mode. The fix forces stdout to binary mode in this case. Task-number: QTBUG-39422 Change-Id: Ib5b5e82db922dc389d160b0115dbafe8641c95fd Reviewed-by: Friedemann Kleint Reviewed-by: Robert Loehning Reviewed-by: Joerg Bornemann Reviewed-by: hjk --- src/tools/rcc/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 5ded9a9b78..0dcbcafb11 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -52,6 +52,10 @@ #include #include +#ifdef Q_OS_WIN +# include +# include +#endif // Q_OS_WIN QT_BEGIN_NAMESPACE @@ -252,6 +256,11 @@ int runRcc(int argc, char *argv[]) if (outFilename.isEmpty() || outFilename == QLatin1String("-")) { +#ifdef Q_OS_WIN + // Make sure fwrite to stdout doesn't do LF->CRLF + if (library.format() == RCCResourceLibrary::Binary) + _setmode(_fileno(stdout), _O_BINARY); +#endif // Q_OS_WIN // using this overload close() only flushes. out.open(stdout, mode); } else { -- cgit v1.2.3