diff options
author | Andy Shaw <andy.shaw@digia.com> | 2013-10-09 13:47:52 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-18 20:05:09 +0200 |
commit | c057e23b02637c1fad270a0cfe2248b50ee418f6 (patch) | |
tree | baa05536c90c9def0dab64d311f1db4b1fbd3f14 | |
parent | a652bab6a7ebf78b029fea95c2801deb6f4f524a (diff) |
When creating QVariant(QPolygonF()) this should be a null variant
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 <stephen.kelly@kdab.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
-rw-r--r-- | src/gui/kernel/qguivariant.cpp | 3 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp | 1 |
2 files changed, 3 insertions, 1 deletions
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<void>(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 Filter> class QGuiVariantIsNull : public QVariantIsNull<Filter> { typedef QVariantIsNull<Filter> Base; @@ -126,6 +126,7 @@ public: template<typename T> bool delegate(const T *p) { return Base::delegate(p); } bool delegate(const QPolygon*) { return v_cast<QPolygon>(Base::m_d)->isEmpty(); } + bool delegate(const QPolygonF*) { return v_cast<QPolygonF>(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; } |