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

6.5: Behavioral change in QTextLine

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.5.0, 6.6.0
    • 6.5
    • GUI: Text handling
    • None
    • 49a63d375 (dev), 78416e0ca (6.5)

    Description

      Calling QTextLine::setLineWidth() with a negative value has a different effect in Qt 6.5 than it had before. It causes the next call of QTextLayout::createLine() to always return a valid line, which results in an endless loop in old code in Qt Creator: QTCREATORBUG-28593

      Minimal reproducer (use in QtC with "New Project -> Other Project -> Code Snippet")
      #include <QApplication>
      #include <QTextLayout>
      
      int textHeightForWidth(int width)
      {
          int height = 0;
          QTextLayout tl("Foo bar und so");
          tl.beginLayout();
          while (true) {
              QTextLine line = tl.createLine();
              if (!line.isValid())
                  break;
              line.setLineWidth(width);
              height += line.height();
          }
          tl.endLayout();
          return height;
      }
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          qDebug() << textHeightForWidth(50);
          qDebug() << textHeightForWidth(-1); // Proceeds with Qt < 6.5, Freezes with Qt 6.5
          return 0;
      }
      

      Surely, it makes little sense to set a negative line width, but perhaps (just like this 15 Years old code in Qt Creator) much code out there expects QTextLine::setLineWidth() behave as before.

      Reverting https://codereview.qt-project.org/c/qt/qtbase/+/435080 brings back the origina behavior.

      Attachments

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              portale Alessandro Portale
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes