aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-08 11:13:42 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-08 20:06:08 +0000
commita7a53d2cacff7b686f6821f87d9fd945806480ed (patch)
tree121a94ddc2ddc811c3d5823db415c900c01eb4df /sources
parent218101668cffbf669ce273b511ed852d8dfbedf5 (diff)
shiboken6/TextStream: Fix the output of empty aligned fields for width=0
Amends 44b03e3ded688aabe8352e8bda66df8677acc8a4. Change-Id: Iab4b9bfd991098fbae261cbe29a2caf13f7ebd3d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit eca89cd04469a61b3c9ee7993122ca1ec3fe976f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp5
-rw-r--r--sources/shiboken6/ApiExtractor/textstream.h2
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);