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

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

XMLWordPrintable

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

      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
      

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

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

              Created:
              Updated:

                There are no open Gerrit changes