mirror of https://github.com/qt/qtbase.git
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 <Friedemann.Kleint@digia.com> Reviewed-by: Robert Loehning <robert.loehning@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
parent
9de7b4d750
commit
bb0263eb80
|
@ -52,6 +52,10 @@
|
|||
#include <qcommandlineoption.h>
|
||||
#include <qcommandlineparser.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
#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 {
|
||||
|
|
Loading…
Reference in New Issue