From 373a7277db0583fbbb8ed61f9f61d6f77ed95da4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Aug 2012 12:06:03 +0200 Subject: QDBusMetaTypeId: don't cache the result of qMetaTypeId<>() in static ints There's not much point in caching the result of qMetaTypeId<>, because it's already internally memoised. In addition, the code that initialised the static int caches wasn't protected against concurrent access under the assumption that the operations performed were thread-safe. That is true for most of them, but not for the stores to the static ints, which race against each other: // Thread A // Thread B r1 = initialized /*=false*/ r1 = initialized /*=false*/ r2 = qMetaTypeId<...>(); r2 = qMetaTypeId<...>(); message = r2; message = r2; // race, ditto for all other ints To fix, turn the ints into inline functions that just call the respective qMetaTypeId<>() function. Change-Id: I5aa80c624872c3867232abc26ffdcde70cd54022 Reviewed-by: Thiago Macieira --- src/dbus/qdbusinterface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/dbus/qdbusinterface.cpp') diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index 47b5b7b173..29d00077ae 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -106,13 +106,13 @@ static void copyArgument(void *to, int id, const QVariant &arg) return; } - if (id == QDBusMetaTypeId::variant) { + if (id == QDBusMetaTypeId::variant()) { *reinterpret_cast(to) = arg.value(); return; - } else if (id == QDBusMetaTypeId::objectpath) { + } else if (id == QDBusMetaTypeId::objectpath()) { *reinterpret_cast(to) = arg.value(); return; - } else if (id == QDBusMetaTypeId::signature) { + } else if (id == QDBusMetaTypeId::signature()) { *reinterpret_cast(to) = arg.value(); return; } @@ -123,7 +123,7 @@ static void copyArgument(void *to, int id, const QVariant &arg) } // if we got here, it's either an un-dermarshalled type or a mismatch - if (arg.userType() != QDBusMetaTypeId::argument) { + if (arg.userType() != QDBusMetaTypeId::argument()) { // it's a mismatch //qWarning? return; -- cgit v1.2.3