diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-08 11:13:42 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-02-08 18:06:08 +0100 |
| commit | eca89cd04469a61b3c9ee7993122ca1ec3fe976f (patch) | |
| tree | d1a6cde1b12d46b8eec5fb7c09279b8758e93848 | |
| parent | db824ef8c01b79a60c8029061eb5c86b51dd87fc (diff) | |
shiboken6/TextStream: Fix the output of empty aligned fields for width=0
Amends 44b03e3ded688aabe8352e8bda66df8677acc8a4.
Pick-to: 6.0
Change-Id: Iab4b9bfd991098fbae261cbe29a2caf13f7ebd3d
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| -rw-r--r-- | sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp | 5 | ||||
| -rw-r--r-- | sources/shiboken6/ApiExtractor/textstream.h | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp index d5c8971cf..366b49799 100644 --- a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp +++ b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp @@ -141,6 +141,8 @@ void TestCodeInjections::testTextStream() << AlignedField("bla", 40, QTextStream::AlignRight) << "|\n|" << AlignedField("bla", 40, QTextStream::AlignLeft) << "|\n|" << AlignedField(QString(), 40, QTextStream::AlignLeft) << "|\n"; + str << "\n2nd table\n|" << AlignedField("bla", 3, QTextStream::AlignLeft) + << '|' << AlignedField(QString{}, 0, QTextStream::AlignLeft) << "|\n"; static const char expected[] = R"(void foo(int a, int b) { if (a == b) @@ -155,6 +157,9 @@ static const char expected[] = R"(void foo(int a, int b) { | bla| |bla | | | + +2nd table +|bla|| )"; QCOMPARE(str.toString(), QLatin1String(expected)); diff --git a/sources/shiboken6/ApiExtractor/textstream.h b/sources/shiboken6/ApiExtractor/textstream.h index 3e66fbf12..3744408b5 100644 --- a/sources/shiboken6/ApiExtractor/textstream.h +++ b/sources/shiboken6/ApiExtractor/textstream.h @@ -170,7 +170,7 @@ public: const auto oldPos = s.pos(); s << m_value; // Ensure something is written when an empty string is encountered - if (oldPos == s.pos()) + if (oldPos == s.pos() && m_fieldWidth > 0) s << ' '; s.setFieldAlignment(oldFieldAlignment); s.setFieldWidth(oldFieldWidth); |
