summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-09-09 08:10:30 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-09-10 08:53:00 (GMT)
commit0b0aa7603b27447a5abe55c55d0514bc56b35f9e (patch)
tree15b4c81d16883e1a2c3b2cc45859a4c383d5e72c /src/corelib/kernel/qobject.h
parent101a63a6fd53e00eaa7e7a56d1ece33327a19bf8 (diff)
downloadQt-0b0aa7603b27447a5abe55c55d0514bc56b35f9e.zip
Qt-0b0aa7603b27447a5abe55c55d0514bc56b35f9e.tar.gz
Qt-0b0aa7603b27447a5abe55c55d0514bc56b35f9e.tar.bz2
Properly implement qobject_cast for const pointers.
Instead of using ugly const_cast in public headers and Q_UNUSED (which expands to nothing in release builds), use a properly-const method. Reviewed-By: Bradley T. Hughes
Diffstat (limited to 'src/corelib/kernel/qobject.h')
-rw-r--r--src/corelib/kernel/qobject.h6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 1b613a6..c533fa1 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -458,14 +458,10 @@ 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>(const_cast<QObject *>(reinterpret_cast<T>(0)->staticMetaObject.cast(const_cast<QObject *>(object))));
+ return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object));
}