From 652be80c25f61aa4fbf28d75ba9971fc709f29c9 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 1 Feb 2010 18:38:35 +0100 Subject: Tests for NaN values in the property x, y, widht and height setters of QGraphicsItem and QmlGraphicsItem Task-number: BAUHAUS-268 Reviewed-by: Thomas Hartmann --- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 8 ++++++++ src/gui/graphicsview/qgraphicsitem.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 2f0c555..6835427 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -62,6 +62,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE #ifndef FLT_MAX @@ -2843,6 +2845,9 @@ qreal QmlGraphicsItem::width() const void QmlGraphicsItem::setWidth(qreal w) { Q_D(QmlGraphicsItem); + if (isnan(w)) + return; + d->widthValid = true; if (d->width == w) return; @@ -2912,6 +2917,9 @@ qreal QmlGraphicsItem::height() const void QmlGraphicsItem::setHeight(qreal h) { Q_D(QmlGraphicsItem); + if (isnan(h)) + return; + d->heightValid = true; if (d->height == h) return; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c53a893..3d81021 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3425,6 +3425,9 @@ void QGraphicsItem::setX(qreal x) if (d_ptr->inDestructor) return; + if (isnan(x)) + return; + d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); } @@ -3449,6 +3452,9 @@ void QGraphicsItem::setY(qreal y) if (d_ptr->inDestructor) return; + if (isnan(y)) + return; + d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); } -- cgit v0.12