diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2014-08-12 13:11:53 +0200 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2014-08-13 00:00:03 +0200 |
commit | 135a2868443a1d9962dece52034db475f3e75036 (patch) | |
tree | 9b6cdfb85c780b78730b30849d6c26da756271d1 /src/widgets/graphicsview | |
parent | 7ca5af28d0591ab34c6ce17ed7b9eff20cca1d67 (diff) |
Fix error reported by address sanitizer
It is not valid to dereference a null pointer, even if it's just in order
to access enum constants
Change-Id: Id404c308ae7ffd879afdd678302e3ac4e0c69001
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index dfc06fdaea..d0c6cc12af 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -1030,14 +1030,16 @@ private: template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item) { - return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type) - || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0; + typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item; + return int(Item::Type) == int(QGraphicsItem::Type) + || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0; } template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item) { - return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type) - || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0; + typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item; + return int(Item::Type) == int(QGraphicsItem::Type) + || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0; } #ifndef QT_NO_DEBUG_STREAM |