Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-20905

QFile setTextModeEnabled() trashes file information

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 4.7.0
    • Fix Version/s: 4.8.x, 5.0.0
    • Labels:
      None
    • Environment:
      pretty much any, but I am using OpenSuSE 11.4 64-bit AMD with all patches applied.
    • Commits:
      29c30a20bab4c4ea892b95c08c71bb5f136bb82c (5.0), e5df3b4eeaf5943f5170dda781c3c589fa35a15a (4.8)

      Description

      #include <QtCore>
      
      int main(int argc, char **argv)
      {
          QFile file("hello.txt");
      
          file.setTextModeEnabled(true);
          file.open(QFile::WriteOnly);
      
          QTextStream stream(&file);
          stream << "Hello World!";
      
          file.close();
      }
      

      roland@linux-c345:~/qt_bug1> ./qt_bug1
      QFile::open: File (hello.txt) already open
      QIODevice::write: ReadOnly device
      roland@linux-c345:~/qt_bug1>

      Setting a flag shouldn't be forcing a file open AND wiping the filename from the object.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-20905
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              shkearns Shane Kearns
              Reporter:
              seasoned_geek Roland Hughes
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes