Ignore:
Timestamp:
Aug 2, 2011, 3:07:49 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

uic: Put stdin/stdout to binary mode on Windows and OS/2.

This is necessary to avoid duplication of CR symbols on output
and hangs in atEnd() due to unexpected CR on input (in particular,
seen when stdin and stdout are redirected to regular files). See
also r932.

Note: it actually may make sense to change QFile::open() so that
it implicitly makes this mode change and restores the origianl mode
on destruction. Just to be on the safe side.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tools/uic/driver.cpp

    r917 r933  
    4747#include <QtCore/QFileInfo>
    4848#include <QtCore/QDebug>
     49
     50
     51
     52
     53
    4954
    5055QT_BEGIN_NAMESPACE
     
    285290{
    286291    QFile f;
    287     if (fileName.isEmpty())
     292    if (fileName.isEmpty()) {
     293#if defined(Q_OS_WIN)
     294        _setmode(_fileno(stdin), _O_BINARY);
     295#elif defined(Q_OS_OS2)
     296        setmode(fileno(stdin), O_BINARY);
     297#endif
    288298        f.open(stdin, QIODevice::ReadOnly);
    289     else {
     299    else {
    290300        f.setFileName(fileName);
    291301        if (!f.open(QIODevice::ReadOnly))
     
    301311        m_output = out;
    302312    } else {
    303 #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
    304         // As one might also redirect the output to a file on win,
    305         // we should not create the textstream with QFile::Text flag.
    306         // The redirected file is opened in TextMode and this will
    307         // result in broken line endings as writing will replace \n again.
    308         m_output = new QTextStream(stdout, QIODevice::WriteOnly);
    309 #else
     313#if defined(Q_WS_WIN)
     314        _setmode(_fileno(stdout), _O_BINARY);
     315#elif defined(Q_OS_OS2)
     316        setmode(fileno(stdout), O_BINARY);
     317#endif
    310318        m_output = new QTextStream(stdout, QIODevice::WriteOnly | QFile::Text);
    311 #endif
    312319        deleteOutput = true;
    313320    }
Note: See TracChangeset for help on using the changeset viewer.