diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-11 07:58:43 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-11 07:59:44 (GMT) |
commit | 288244c528ca169d1a3b015e27fc9561d7094563 (patch) | |
tree | 14a31a414b819eee2d558f60b7bc35e6eeede201 /src | |
parent | ef96f3f480527e5fde2aba10a55e87dd348ddb9a (diff) | |
download | Qt-288244c528ca169d1a3b015e27fc9561d7094563.zip Qt-288244c528ca169d1a3b015e27fc9561d7094563.tar.gz Qt-288244c528ca169d1a3b015e27fc9561d7094563.tar.bz2 |
Revert "Properly implement qobject_cast for const pointers."
This commit added new symbols to the 4.7 branch after 4.7.0 was
frozen.
This reverts commit 0b0aa7603b27447a5abe55c55d0514bc56b35f9e.
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 20 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.h | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 1 |
3 files changed, 6 insertions, 21 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 3b9b04a..9854e68 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -266,25 +266,7 @@ QObject *QMetaObject::cast(QObject *obj) const const QMetaObject *m = obj->metaObject(); do { if (m == this) - return obj; - } while ((m = m->d.superdata)); - } - return 0; -} - -/*! - \internal - - Returns \a obj if object \a obj inherits from this - meta-object; otherwise returns 0. -*/ -const QObject *QMetaObject::cast(const QObject *obj) const -{ - if (obj) { - const QMetaObject *m = obj->metaObject(); - do { - if (m == this) - return obj; + return const_cast<QObject*>(obj); } while ((m = m->d.superdata)); } return 0; diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index b5c772e..d98d1f0 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -369,10 +369,14 @@ inline T qobject_cast(QObject *object) template <class T> inline T qobject_cast(const QObject *object) { + // this will cause a compilation error if T is not const + register T ptr = static_cast<T>(object); + Q_UNUSED(ptr); + #if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) reinterpret_cast<T>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object))); #endif - return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object)); + return static_cast<T>(const_cast<QObject *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<QObject *>(object)))); } diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 0d045dc..555a1f5 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -298,7 +298,6 @@ struct Q_CORE_EXPORT QMetaObject const QMetaObject *superClass() const; QObject *cast(QObject *obj) const; - const QObject *cast(const QObject *obj) const; #ifndef QT_NO_TRANSLATION // ### Qt 4: Merge overloads |