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

QPlainTextEdit::setPlainText goes to infinite loop

    XMLWordPrintable

Details

    • 3841a7dd49667ceabdcbc416fa1e149bed7ed86e

    Description

      Following code causes the application to go busy loop 

      #include <QApplication>
      #include <QPlainTextEdit>
      
      int main(int argc,char*args[])
      {
          QApplication app(argc,args);
          QPlainTextEdit *comment = new QPlainTextEdit();
          comment->setPlainText("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nX\nX\nX");
          auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
          comment->setFont(font);
          comment->setWordWrapMode(QTextOption::NoWrap);
          comment->setFixedSize(300,72);
          comment->show();
      
          return app.exec();
      }
      

       Looks like the same sequence of event is posted again and again on the event loop: 

      QScrollBar - UpdateLater 
      QWidget - UpdateLater 
      QWidget - MetaCall 
      QWidget - ZOrderChange 
      QScrollBar - Show 
      QWidget - Show 
      QWidget - ShowToParent 
      QWidget - Hide 
      QScrollBar - Hide 
      QWidget - HideToParent 
      QWidget - Resize 
      QWidget - MetaCall 
      QWidget - ZOrderChange 
      QWidget - Hide 
      QScrollBar - Hide 
      QWidget - HideToParent 
      QScrollBar - Show 
      QWidget - Show 
      QWidget - ShowToParent 
      QWidget - Resize

       
      It looks like the QScrollBars are alternatively hiden and shown. As the event loop is 100% busy, the app is unresponsive.

      This happens if there is exactly three \nX at the end of the text line and the font is FixedFont. 

      Attachments

        1. qtdiag.txt
          6 kB
        2. QTBUG-62818.zip
          1 kB
        3. qtbug62818.zip
          2 kB

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              misalmel Mika Salmela
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes