diff options
Diffstat (limited to 'tests/auto/gui/text/qrawfont/tst_qrawfont.cpp')
-rw-r--r-- | tests/auto/gui/text/qrawfont/tst_qrawfont.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index 37f94d0278..373ad7fef9 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -93,6 +93,9 @@ private slots: void fallbackFontsOrder(); + void qtbug65923_partal_clone_data(); + void qtbug65923_partal_clone(); + private: QString testFont; QString testFontBoldItalic; @@ -1044,6 +1047,42 @@ void tst_QRawFont::fallbackFontsOrder() fontDatabase.removeApplicationFont(id); } +void tst_QRawFont::qtbug65923_partal_clone_data() +{ + QTest::addColumn<bool>("shouldClone"); + + QTest::newRow("Without cloning font engine") << false; + QTest::newRow("Cloning font engine") << true; +} + +void tst_QRawFont::qtbug65923_partal_clone() +{ + QFile file(testFont); + file.open(QIODevice::ReadOnly); + QByteArray fontData = file.readAll(); + + QRawFont outerFont; + + { + QRawFont innerFont(fontData, 16, QFont::PreferDefaultHinting); + + QFETCH(bool, shouldClone); + if (shouldClone) { + // This will trigger QFontEngine::cloneWithSize + innerFont.setPixelSize(innerFont.pixelSize() + 1); + } + + outerFont = innerFont; + } + + // This will detach if data is shared with the raw font. If the raw font has + // a naked reference to the data, without informing Qt of it via the ref count + // of the byte array, this will result in clearing 'live' data. + fontData.fill('\0'); + + QVERIFY(!outerFont.boundingRect(42).isEmpty()); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QRawFont) |