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 inline T qgraphicsitem_cast(QGraphicsItem *item) { - return int(static_cast(0)->Type) == int(QGraphicsItem::Type) - || (item && int(static_cast(0)->Type) == item->type()) ? static_cast(item) : 0; + typedef typename QtPrivate::remove_cv::type>::type Item; + return int(Item::Type) == int(QGraphicsItem::Type) + || (item && int(Item::Type) == item->type()) ? static_cast(item) : 0; } template inline T qgraphicsitem_cast(const QGraphicsItem *item) { - return int(static_cast(0)->Type) == int(QGraphicsItem::Type) - || (item && int(static_cast(0)->Type) == item->type()) ? static_cast(item) : 0; + typedef typename QtPrivate::remove_cv::type>::type Item; + return int(Item::Type) == int(QGraphicsItem::Type) + || (item && int(Item::Type) == item->type()) ? static_cast(item) : 0; } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 4f817a3353..94ec55002a 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -666,9 +666,10 @@ protected: template T qstyleoption_cast(const QStyleOption *opt) { - if (opt && opt->version >= static_cast(0)->Version && (opt->type == static_cast(0)->Type - || int(static_cast(0)->Type) == QStyleOption::SO_Default - || (int(static_cast(0)->Type) == QStyleOption::SO_Complex + typedef typename QtPrivate::remove_cv::type>::type Opt; + if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type + || int(Opt::Type) == QStyleOption::SO_Default + || (int(Opt::Type) == QStyleOption::SO_Complex && opt->type > QStyleOption::SO_Complex))) return static_cast(opt); return 0; @@ -677,9 +678,10 @@ T qstyleoption_cast(const QStyleOption *opt) template T qstyleoption_cast(QStyleOption *opt) { - if (opt && opt->version >= static_cast(0)->Version && (opt->type == static_cast(0)->Type - || int(static_cast(0)->Type) == QStyleOption::SO_Default - || (int(static_cast(0)->Type) == QStyleOption::SO_Complex + typedef typename QtPrivate::remove_cv::type>::type Opt; + if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type + || int(Opt::Type) == QStyleOption::SO_Default + || (int(Opt::Type) == QStyleOption::SO_Complex && opt->type > QStyleOption::SO_Complex))) return static_cast(opt); return 0; @@ -727,8 +729,9 @@ public: template T qstyleoption_cast(const QStyleHintReturn *hint) { - if (hint && hint->version <= static_cast(0)->Version && - (hint->type == static_cast(0)->Type || int(static_cast(0)->Type) == QStyleHintReturn::SH_Default)) + typedef typename QtPrivate::remove_cv::type>::type Opt; + if (hint && hint->version <= Opt::Version && + (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default)) return static_cast(hint); return 0; } @@ -736,8 +739,9 @@ T qstyleoption_cast(const QStyleHintReturn *hint) template T qstyleoption_cast(QStyleHintReturn *hint) { - if (hint && hint->version <= static_cast(0)->Version && - (hint->type == static_cast(0)->Type || int(static_cast(0)->Type) == QStyleHintReturn::SH_Default)) + typedef typename QtPrivate::remove_cv::type>::type Opt; + if (hint && hint->version <= Opt::Version && + (hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default)) return static_cast(hint); return 0; }