diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-05-05 07:44:58 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-31 14:32:44 (GMT) |
commit | bc3491c1b85ca36486c9472ecf7ba82f46699e8a (patch) | |
tree | d08c3752f6e0656974c18eb654811f889276366a /src/corelib/kernel/qobjectdefs.h | |
parent | d7ee1cc6456e35823d2c470feec6219ef516e1f6 (diff) | |
download | Qt-bc3491c1b85ca36486c9472ecf7ba82f46699e8a.zip Qt-bc3491c1b85ca36486c9472ecf7ba82f46699e8a.tar.gz Qt-bc3491c1b85ca36486c9472ecf7ba82f46699e8a.tar.bz2 |
Speedup activation of signals
The virtual QObject::qt_metacall will recurse to the whole object hierarchy
to find from which class a function should be called.
But it is possible to know, at connection time, from which exact
QMetaObject a function belongs, and the relative offset into it.
So we make the slot calls from the qt_static_metacall function.
So activation of signals is faster.
- We must not call a slot from a class that has been destroyed.
To avoid this, there is a check on the methodOffset. If it is
smaller, that means we might be called (indirectly) from
the destructor. We fallback to the virtual call to qt_metacall
that does the right thing.
- The signature of the static method is void (*) (QObject*,MetaCall,int,void**)
It returns void, so the compiler is allowed to do tail recusive
optimization. Having the QObject* as first parameter make it ready
on the stack for the call to the member function.
- The new static method has to be a member function in order to
be able to access the private slots.
Reviewed-by: brad
Diffstat (limited to 'src/corelib/kernel/qobjectdefs.h')
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 54b5ab2..6bf40f7 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -55,7 +55,7 @@ class QByteArray; class QString; #ifndef Q_MOC_OUTPUT_REVISION -#define Q_MOC_OUTPUT_REVISION 62 +#define Q_MOC_OUTPUT_REVISION 63 #endif // The following macros are our "extensions" to C++ @@ -163,6 +163,7 @@ public: \ virtual void *qt_metacast(const char *); \ QT_TR_FUNCTIONS \ virtual int qt_metacall(QMetaObject::Call, int, void **); \ + static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ private: /* tmake ignore Q_OBJECT */ #define Q_OBJECT_FAKE Q_OBJECT @@ -468,7 +469,6 @@ struct Q_CORE_EXPORT QMetaObject const uint *data; const void *extradata; } d; - }; typedef const QMetaObject& (*QMetaObjectAccessor)(); @@ -480,7 +480,8 @@ struct QMetaObjectExtraData #else const QMetaObject **objects; #endif - int (*static_metacall)(QMetaObject::Call, int, void **); + void (*static_metacall)(QObject *, QMetaObject::Call, int, void **); //from revision 6 + //int (*static_metacall)(QMetaObject::Call, int, void **); //used from revison 2 until revison 5 }; inline const char *QMetaObject::className() const |