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

QTextStream's character-reading operator blocks for a non-whitespace character.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 4.8.5, 5.2.1
    • Core: I/O
    • None

    Description

      Suppose you're reading from standard input or from a network stream using QTextStream. You read a numeric value, and then you read a single character.

      • The single character read will be the newline terminating the previous numeric value. This is seemingly correct, although different from iostream's behavior - perhaps it should be better documented?
      • What's incorrect is that operator>>(char&) and operator>>(QChar&) waits for a non-whitespace character in spite of there already being a newline in the buffer.
      QTextStream cin(stdin);
      
      int a;
      char b;
      
      cin >> a;
      cin >> b; // blocks for non-whitespace input in spite of there being whitespace input available
      
      #ifdef Q_OS_UNIX
      Q_ASSERT(b == '\n')
      #endif
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            kuba Kuba Ober
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes