Inline QMetaObject::cast(QObject *), as requested by ### Qt 6 comment

Task-number: QTBUG-85700
Change-Id: I29405df37b82d34a92537e39a3863b5f6c998556
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Edward Welbourne 2020-08-31 11:57:00 +02:00
parent 4b9ec075f8
commit 2c63164012
2 changed files with 5 additions and 8 deletions

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
@ -358,16 +358,12 @@ bool QMetaObject::inherits(const QMetaObject *metaObject) const noexcept
}
/*!
\fn QObject *QMetaObject::cast(QObject *obj) const
\internal
Returns \a obj if object \a obj inherits from this
meta-object; otherwise returns \nullptr.
*/
QObject *QMetaObject::cast(QObject *obj) const
{
// ### Qt 6: inline
return const_cast<QObject*>(cast(const_cast<const QObject*>(obj)));
}
/*!
\internal

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2019 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@ -165,7 +165,8 @@ struct Q_CORE_EXPORT QMetaObject
const QMetaObject *superClass() const;
bool inherits(const QMetaObject *metaObject) const noexcept;
QObject *cast(QObject *obj) const;
QObject *cast(QObject *obj) const
{ return const_cast<QObject *>(cast(const_cast<const QObject *>(obj))); }
const QObject *cast(const QObject *obj) const;
#if !defined(QT_NO_TRANSLATION) || defined(Q_CLANG_QDOC)