Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5
-
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
#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
- is duplicated by
-
QTCREATORBUG-28593 If built against Qt 6.5, Qt Creator hangs when showing the Issues pane
- Closed
- relates to
-
QTBUG-115459 Possible infinite loop triggered by unmaximizing the window in 6.5.0+
- Closed