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>
This commit is contained in:
parent
7ca5af28d0
commit
135a286844
@ -1030,14 +1030,16 @@ private:
|
|||||||
|
|
||||||
template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item)
|
template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type)
|
typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item;
|
||||||
|| (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0;
|
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)
|
template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type)
|
typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item;
|
||||||
|| (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0;
|
return int(Item::Type) == int(QGraphicsItem::Type)
|
||||||
|
|| (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
@ -666,9 +666,10 @@ protected:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T qstyleoption_cast(const QStyleOption *opt)
|
T qstyleoption_cast(const QStyleOption *opt)
|
||||||
{
|
{
|
||||||
if (opt && opt->version >= static_cast<T>(0)->Version && (opt->type == static_cast<T>(0)->Type
|
typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
|
||||||
|| int(static_cast<T>(0)->Type) == QStyleOption::SO_Default
|
if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
|
||||||
|| (int(static_cast<T>(0)->Type) == QStyleOption::SO_Complex
|
|| int(Opt::Type) == QStyleOption::SO_Default
|
||||||
|
|| (int(Opt::Type) == QStyleOption::SO_Complex
|
||||||
&& opt->type > QStyleOption::SO_Complex)))
|
&& opt->type > QStyleOption::SO_Complex)))
|
||||||
return static_cast<T>(opt);
|
return static_cast<T>(opt);
|
||||||
return 0;
|
return 0;
|
||||||
@ -677,9 +678,10 @@ T qstyleoption_cast(const QStyleOption *opt)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T qstyleoption_cast(QStyleOption *opt)
|
T qstyleoption_cast(QStyleOption *opt)
|
||||||
{
|
{
|
||||||
if (opt && opt->version >= static_cast<T>(0)->Version && (opt->type == static_cast<T>(0)->Type
|
typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
|
||||||
|| int(static_cast<T>(0)->Type) == QStyleOption::SO_Default
|
if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
|
||||||
|| (int(static_cast<T>(0)->Type) == QStyleOption::SO_Complex
|
|| int(Opt::Type) == QStyleOption::SO_Default
|
||||||
|
|| (int(Opt::Type) == QStyleOption::SO_Complex
|
||||||
&& opt->type > QStyleOption::SO_Complex)))
|
&& opt->type > QStyleOption::SO_Complex)))
|
||||||
return static_cast<T>(opt);
|
return static_cast<T>(opt);
|
||||||
return 0;
|
return 0;
|
||||||
@ -727,8 +729,9 @@ public:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T qstyleoption_cast(const QStyleHintReturn *hint)
|
T qstyleoption_cast(const QStyleHintReturn *hint)
|
||||||
{
|
{
|
||||||
if (hint && hint->version <= static_cast<T>(0)->Version &&
|
typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
|
||||||
(hint->type == static_cast<T>(0)->Type || int(static_cast<T>(0)->Type) == QStyleHintReturn::SH_Default))
|
if (hint && hint->version <= Opt::Version &&
|
||||||
|
(hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
|
||||||
return static_cast<T>(hint);
|
return static_cast<T>(hint);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -736,8 +739,9 @@ T qstyleoption_cast(const QStyleHintReturn *hint)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
T qstyleoption_cast(QStyleHintReturn *hint)
|
T qstyleoption_cast(QStyleHintReturn *hint)
|
||||||
{
|
{
|
||||||
if (hint && hint->version <= static_cast<T>(0)->Version &&
|
typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
|
||||||
(hint->type == static_cast<T>(0)->Type || int(static_cast<T>(0)->Type) == QStyleHintReturn::SH_Default))
|
if (hint && hint->version <= Opt::Version &&
|
||||||
|
(hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
|
||||||
return static_cast<T>(hint);
|
return static_cast<T>(hint);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user