diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-08 12:34:12 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-08 20:55:34 +0000 |
commit | 0be189aed9f554f0a2d7427a90fd0aaa692e459f (patch) | |
tree | 3ed0fe3704cdd1eb2960368b1b5864c7fd67e233 | |
parent | a7a53d2cacff7b686f6821f87d9fd945806480ed (diff) |
shiboken6/Documentation: Fix table width determination
Initialize the width/height lists to 0.
As a drive-by, use the number of lines from splitting
instead of counting.
Change-Id: Ib17ed819684298599d3c01cf00cfc8b5c192d232
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit ad01b159e02067ba46d6433412cb1e690553e946)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp index 66c267852..10a97549d 100644 --- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp +++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp @@ -1304,15 +1304,15 @@ void QtXmlToSphinx::Table::format(TextStream& s) const // calc width and height of each column and row const int headerColumnCount = m_rows.constFirst().count(); - QList<int> colWidths(headerColumnCount); - QList<int> rowHeights(m_rows.count()); + QList<int> colWidths(headerColumnCount, 0); + QList<int> rowHeights(m_rows.count(), 0); for (int i = 0, maxI = m_rows.count(); i < maxI; ++i) { const QtXmlToSphinx::TableRow& row = m_rows.at(i); for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) { const auto rowLines = QStringView{row[j].data}.split(QLatin1Char('\n')); // cache this would be a good idea for (const auto &str : rowLines) colWidths[j] = std::max(colWidths[j], int(str.size())); - rowHeights[i] = std::max(rowHeights[i], int(row[j].data.count(QLatin1Char('\n')) + 1)); + rowHeights[i] = std::max(rowHeights[i], int(rowLines.size())); } } |