From 86a4c81e581075b6d3e047f837c65d5b214276d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 16 Feb 2018 13:22:26 +0100 Subject: shiboken/docgenerator: Pad table rows up to header column count Fix a warning about a malformed table (qcursor.cpp) whose last row has too few columns. Task-number: PYSIDE-363 Change-Id: I5eec88226e48064ee54e3abe1247d9dc06dc1d82 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Alexandru Croitor --- sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sources/shiboken2/generator/qtdoc') diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index 7d92c5380..169e6591f 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -1028,7 +1028,8 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table) } // calc width and height of each column and row - QVector colWidths(table.first().count()); + const int headerColumnCount = table.constFirst().count(); + QVector colWidths(headerColumnCount); QVector rowHeights(table.count()); for (int i = 0, maxI = table.count(); i < maxI; ++i) { const QtXmlToSphinx::TableRow& row = table[i]; @@ -1056,7 +1057,7 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table) // print line s << INDENT << '+'; - for (int col = 0, max = colWidths.count(); col < max; ++col) { + for (int col = 0; col < headerColumnCount; ++col) { char c; if (col >= row.length() || row[col].rowSpan == -1) c = ' '; @@ -1071,7 +1072,8 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table) // Print the table cells for (int rowLine = 0; rowLine < rowHeights[i]; ++rowLine) { // for each line in a row - for (int j = 0, maxJ = std::min(row.count(), colWidths.size()); j < maxJ; ++j) { // for each column + int j = 0; + for (int maxJ = std::min(row.count(), headerColumnCount); j < maxJ; ++j) { // for each column const QtXmlToSphinx::TableCell& cell = row[j]; const QVector rowLines = cell.data.splitRef(QLatin1Char('\n')); // FIXME: Cache this!!! if (!j) // First column, so we need print the identation @@ -1086,6 +1088,8 @@ QTextStream& operator<<(QTextStream& s, const QtXmlToSphinx::Table &table) else s << Pad(' ', colWidths.at(j)); } + for ( ; j < headerColumnCount; ++j) // pad + s << '|' << Pad(' ', colWidths.at(j)); s << '|' << endl; } } -- cgit v1.2.3