summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject_impl.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-08-20 15:52:19 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-26 14:34:13 +0200
commite6c50609c8a098304ab6b2a41aa371563ba45d2e (patch)
tree635a0e64a9a9addf6b4d0d3bfefb2a3e2e85e37d /src/corelib/kernel/qobject_impl.h
parent2d78e241918453a978f46a6246234cff881e9174 (diff)
QSlotObjectBase: make 'impl' and 'ref' private
This allows to fold the deref() and the destroy() operations into one, destroyIfLastRef(). The member variables were renamed since there's now a member function of the same name (ref()). Change-Id: Ib94416d9e658065bbf5d3711ecafaf0eb063af17 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/kernel/qobject_impl.h')
-rw-r--r--src/corelib/kernel/qobject_impl.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 9eda421f0e..3ed47082f1 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -101,13 +101,13 @@ namespace QtPrivate {
#endif
// internal base class (interface) containing functions required to call a slot managed by a pointer to function.
- struct QSlotObjectBase {
- QAtomicInt ref;
+ class QSlotObjectBase {
+ QAtomicInt m_ref;
// don't use virtual functions here; we don't want the
// compiler to create tons of per-polymorphic-class stuff that
// we'll never need. We just use one function pointer.
typedef void (*ImplFn)(int which, QSlotObjectBase* this_, QObject *receiver, void **args, bool *ret);
- const ImplFn impl;
+ const ImplFn m_impl;
protected:
enum Operation {
Destroy,
@@ -117,11 +117,14 @@ namespace QtPrivate {
NumOperations
};
public:
- explicit QSlotObjectBase(ImplFn fn) : ref(1), impl(fn) {}
+ explicit QSlotObjectBase(ImplFn fn) : m_ref(1), m_impl(fn) {}
- inline void destroy() { impl(Destroy, this, 0, 0, 0); }
- inline bool compare(void **a) { bool ret; impl(Compare, this, 0, a, &ret); return ret; }
- inline void call(QObject *r, void **a) { impl(Call, this, r, a, 0); }
+ inline int ref() Q_DECL_NOTHROW { return m_ref.ref(); }
+ inline void destroyIfLastRef() Q_DECL_NOTHROW
+ { if (!m_ref.deref()) m_impl(Destroy, this, 0, 0, 0); }
+
+ inline bool compare(void **a) { bool ret; m_impl(Compare, this, 0, a, &ret); return ret; }
+ inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, 0); }
protected:
~QSlotObjectBase() {}
};