From c057e23b02637c1fad270a0cfe2248b50ee418f6 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 9 Oct 2013 13:47:52 +0200 Subject: When creating QVariant(QPolygonF()) this should be a null variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handling of the null QPolygonF case was not correct as it would always be seen as valid. This ensures it is treated in the same way as QPolygon when it is in fact null. [ChangeLog][QtGui][QPolygonF] When a QVariant holds a QPolygonF() then it will be correctly seen as a null QVariant. Change-Id: Icae34f513c3a8e1dd3f50cb64a3d13ae7c636cc4 Reviewed-by: Stephen Kelly Reviewed-by: Jędrzej Nowacki --- src/gui/kernel/qguivariant.cpp | 3 ++- tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index 2842211e1d..b4e936f818 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -115,7 +115,7 @@ static void clear(QVariant::Private *d) QMetaTypeSwitcher::switcher(destructor, d->type, 0); } -// This class is a hack that customizes access to QPolygon +// This class is a hack that customizes access to QPolygon and QPolygonF template class QGuiVariantIsNull : public QVariantIsNull { typedef QVariantIsNull Base; @@ -126,6 +126,7 @@ public: template bool delegate(const T *p) { return Base::delegate(p); } bool delegate(const QPolygon*) { return v_cast(Base::m_d)->isEmpty(); } + bool delegate(const QPolygonF*) { return v_cast(Base::m_d)->isEmpty(); } bool delegate(const void *p) { return Base::delegate(p); } }; static bool isNull(const QVariant::Private *d) diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 8a68f40f3f..4b2cce63e5 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -526,6 +526,7 @@ void tst_QGuiVariant::writeToReadFromDataStream_data() QTest::newRow( "pointarray_valid" ) << QVariant::fromValue( QPolygon( QRect( 10, 10, 20, 20 ) ) ) << false; QTest::newRow( "region_invalid" ) << QVariant::fromValue( QRegion() ) << true; QTest::newRow( "region_valid" ) << QVariant::fromValue( QRegion( 10, 10, 20, 20 ) ) << false; + QTest::newRow("polygonf_invalid") << QVariant::fromValue(QPolygonF()) << true; QTest::newRow("polygonf_valid") << QVariant::fromValue(QPolygonF(QRectF(10, 10, 20, 20))) << false; } -- cgit v1.2.3