aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-16 13:22:26 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-20 15:07:55 +0000
commit86a4c81e581075b6d3e047f837c65d5b214276d4 (patch)
tree63feb83e14dd61a35b9aecc023b84bb194e9ac99 /sources
parent03a96967b8c8936c37ff1e4c93a50c6d064216b9 (diff)
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 <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp10
1 files changed, 7 insertions, 3 deletions
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<int> colWidths(table.first().count());
+ const int headerColumnCount = table.constFirst().count();
+ QVector<int> colWidths(headerColumnCount);
QVector<int> 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<QStringRef> 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;
}
}