Skip to content

Commit

Permalink
add some patches for building qt-5.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Mar 20, 2019
1 parent 00b8d80 commit 65d8ecd
Show file tree
Hide file tree
Showing 3 changed files with 525 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/qt512.2_avoid_qtabbar_segfault.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- qtbase/src/widgets/widgets/qtabbar.cpp.orig 2019-03-19 12:24:14.000000000 -0400
+++ qtbase/src/widgets/widgets/qtabbar.cpp 2019-03-19 12:23:40.000000000 -0400
@@ -738,6 +738,8 @@
{
Q_Q(QTabBar);
Q_ASSERT(index >= 0);
+ // play it safe
+ if (index < 0) return;

Tab &tab = tabList[index];
bool vertical = verticalTabs(shape);
68 changes: 68 additions & 0 deletions docs/qt512.2_qtableview_fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git qtbase/src/widgets/styles/qcommonstyle.cpp qtbase/src/widgets/styles/qcommonstyle.cpp
index 79e338a6e7..c739ddc6e2 100644
--- qtbase/src/widgets/styles/qcommonstyle.cpp
+++ qtbase/src/widgets/styles/qcommonstyle.cpp
@@ -843,11 +843,14 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
}
#endif // QT_CONFIG(toolbutton)

-static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
+static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr)
{
+ if (lastVisibleLine)
+ *lastVisibleLine = -1;
qreal height = 0;
qreal widthUsed = 0;
textLayout.beginLayout();
+ int i = 0;
while (true) {
QTextLine line = textLayout.createLine();
if (!line.isValid())
@@ -856,6 +859,13 @@ static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth)
line.setPosition(QPointF(0, height));
height += line.height();
widthUsed = qMax(widthUsed, line.naturalTextWidth());
+ // we assume that the height of the next line is the same as the current one
+ if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) {
+ const QTextLine nextLine = textLayout.createLine();
+ *lastVisibleLine = nextLine.isValid() ? i : -1;
+ break;
+ }
+ ++i;
}
textLayout.endLayout();
return QSizeF(widthUsed, height);
@@ -869,7 +879,13 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
QTextLayout textLayout(text, font);
textLayout.setTextOption(textOption);

- viewItemTextLayout(textLayout, textRect.width());
+ // In AlignVCenter mode when more than one line is displayed and the height only allows
+ // some of the lines it makes no sense to display those. From a users perspective it makes
+ // more sense to see the start of the text instead something inbetween.
+ const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter);
+
+ int lastVisibleLine = -1;
+ viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine);

const QRectF boundingRect = textLayout.boundingRect();
// don't care about LTR/RTL here, only need the height
@@ -896,7 +912,7 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
const int start = line.textStart();
const int length = line.textLength();
const bool drawElided = line.naturalTextWidth() > textRect.width();
- bool elideLastVisibleLine = false;
+ bool elideLastVisibleLine = lastVisibleLine == i;
if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) {
const QTextLine nextLine = textLayout.lineAt(i + 1);
const int nextHeight = height + nextLine.height() / 2;
@@ -927,7 +943,8 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex
}

// below visible text, can stop
- if (height + layoutRect.top() >= textRect.bottom())
+ if ((height + layoutRect.top() >= textRect.bottom()) ||
+ (lastVisibleLine >= 0 && lastVisibleLine == i))
break;
}
return ret;
Loading

0 comments on commit 65d8ecd

Please sign in to comment.