aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4managed_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2014-10-30 22:30:01 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-10-31 15:42:42 +0100
commit0704d2be63b484cb579c1507223db3f914b1338a (patch)
tree66d4e616545d7f576125e85cc108c7e2988cecdd /src/qml/jsruntime/qv4managed_p.h
parente67948823d6810c2de784859da52a261bf80b550 (diff)
Get rid of !this and similar constructs
The C++ standard doesn't allow calling member functions on a mull object. Fix all such places, by moving the checks to the caller where required. Change-Id: I10fb22acaf0324d8ffd3a6d8e19152e5d32f56bb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4managed_p.h')
-rw-r--r--src/qml/jsruntime/qv4managed_p.h16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index ce0ee973e8..e679017b7e 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -269,9 +269,7 @@ public:
template <typename T>
T *as() {
- // ### FIXME:
- if (!this || !internalClass())
- return 0;
+ Q_ASSERT(internalClass());
#if !defined(QT_NO_QOBJECT_CHECK)
static_cast<T *>(this)->qt_check_for_QMANAGED_macro(static_cast<T *>(this));
#endif
@@ -285,9 +283,7 @@ public:
}
template <typename T>
const T *as() const {
- // ### FIXME:
- if (!this)
- return 0;
+ Q_ASSERT(internalClass());
#if !defined(QT_NO_QOBJECT_CHECK)
static_cast<T *>(this)->qt_check_for_QMANAGED_macro(static_cast<T *>(const_cast<Managed *>(this)));
#endif
@@ -362,23 +358,23 @@ inline Managed *value_cast(const Value &v) {
template<typename T>
inline T *managed_cast(Managed *m)
{
- return m->as<T>();
+ return m ? m->as<T>() : 0;
}
template<>
inline String *managed_cast(Managed *m)
{
- return m->asString();
+ return m ? m->asString() : 0;
}
template<>
inline Object *managed_cast(Managed *m)
{
- return m->asObject();
+ return m ? m->asObject() : 0;
}
template<>
inline FunctionObject *managed_cast(Managed *m)
{
- return m->asFunctionObject();
+ return m ? m->asFunctionObject() : 0;
}
}