aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-08 22:23:00 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-02-10 09:38:18 +0100
commitb13a1e9f7642bd73a0905836654c24e28b07d2b2 (patch)
tree1c799033e251e086a1214a4a500f7fa9477db6ad
parentcc22cec1e61906408ba696fd6b5243c14b4a7f77 (diff)
shiboken6/Documentation: Fix formatting tables on QIODevices
Flush the device before returning the position which is used in the AlignedField helper. Task-number: PYSIDE-841 Change-Id: Id1be81d2819f9682267930076898c79cd68c2bbf Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit da15fc958dafc51901431cf5d9b98b082c8c2690)
-rw-r--r--sources/shiboken6/ApiExtractor/textstream.cpp2
-rw-r--r--sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp20
-rw-r--r--sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h2
3 files changed, 24 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/textstream.cpp b/sources/shiboken6/ApiExtractor/textstream.cpp
index f3b2dd13f..364634f2d 100644
--- a/sources/shiboken6/ApiExtractor/textstream.cpp
+++ b/sources/shiboken6/ApiExtractor/textstream.cpp
@@ -70,6 +70,8 @@ qint64 TextStream::pos() const
// QTextStream::pos() only works for QIODevice, be a bit smarter
if (auto s = m_str.string())
return s->size();
+ // QIODevices need to flushed to tell the correct position.
+ const_cast<QTextStream &>(m_str).flush();
return m_str.pos();
}
diff --git a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp
index 5bac4d956..c9aebc443 100644
--- a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp
+++ b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.cpp
@@ -431,4 +431,24 @@ void QtXmlToSphinxTest::testTableFormatting()
QCOMPARE(actual, expected);
}
+void QtXmlToSphinxTest::testTableFormattingIoDevice_data()
+{
+ testTableFormatting_data();
+}
+
+void QtXmlToSphinxTest::testTableFormattingIoDevice()
+{
+ QFETCH(TablePtr, table);
+ QFETCH(QString, expected);
+
+ QByteArray byteArray;
+ {
+ TextStream str(&byteArray);
+ table->format(str);
+ }
+ const QString actual = QString::fromUtf8(byteArray);
+
+ QCOMPARE(actual, expected);
+}
+
QTEST_APPLESS_MAIN( QtXmlToSphinxTest)
diff --git a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h
index 0459fdb6d..083ebb091 100644
--- a/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h
+++ b/sources/shiboken6/tests/qtxmltosphinxtest/qtxmltosphinxtest.h
@@ -49,6 +49,8 @@ private slots:
void testTable();
void testTableFormatting_data();
void testTableFormatting();
+ void testTableFormattingIoDevice_data();
+ void testTableFormattingIoDevice();
private:
QString transformXml(const QString &xml) const;