diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-07-20 10:34:27 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-24 20:11:05 +0200 |
commit | e9ecf1b420d8f0fc4393cbfdea2fe731409d83c6 (patch) | |
tree | d9a13f2e48954c6dac35f6b43d3fabc6ebbc831f /src/dbus/qdbuserror.h | |
parent | 95232af3effab1f722c31e136c59fdd4ae3967b1 (diff) |
QtDBus: use qMetaTypeId<T>() instead of qRegisterMetaType<T>("T")
Using qMetaTypeId<T> has the advantage that multiple calls during
a program run are much more efficient, since an inlined atomic
is used to store the result. It also ensures that
Q_DECLARE_METATYPE(T) has been used, whereas qRegisterMetaType<T>
(the unary version) will happily register anything.
Had to add a proper default constructor to QDBusError, as the
one doubling as the default constructor wasn't available under
QT_BOOTSTRAP, but Q_DECLARE_METATYPE requires a default ctor.
Also changed a nullary qRegisterMetaType() to qMetaTypeId() in
qDBusRegisterMetaType(). They're equivalent, since the former
just calls the latter, but apart from the miniscule optimisation
that the compiler has to instantiate one function less, the result
is also used, so using qMetaTypeId() better expresses what 'id'
is.
Change-Id: Ib9dde17923ab9ee55f9464138a625ab8cd55c482
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/dbus/qdbuserror.h')
-rw-r--r-- | src/dbus/qdbuserror.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index a6b3c9a70a..52e65d677d 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -95,8 +95,9 @@ public: #endif }; + QDBusError(); #ifndef QT_BOOTSTRAPPED - explicit QDBusError(const DBusError *error = 0); + explicit QDBusError(const DBusError *error); /*implicit*/ QDBusError(const QDBusMessage& msg); #endif QDBusError(ErrorType error, const QString &message); @@ -126,6 +127,8 @@ Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusError &); QT_END_NAMESPACE +Q_DECLARE_METATYPE(QDBusError) + QT_END_HEADER #endif // QT_NO_DBUS |