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>
This commit is contained in:
Andy Shaw 2013-10-09 13:47:52 +02:00 committed by The Qt Project
parent a652bab6a7
commit c057e23b02
2 changed files with 3 additions and 1 deletions

View File

@ -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)

View File

@ -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;
}