diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-08-24 12:06:03 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-22 19:19:37 +0200 |
commit | 373a7277db0583fbbb8ed61f9f61d6f77ed95da4 (patch) | |
tree | f530a3e205770802a2580789e8e5eb487065fedb /src/dbus/qdbusxmlgenerator.cpp | |
parent | f799e57151dbd236f30d4ffb20d6c331b6e1a388 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusxmlgenerator.cpp')
-rw-r--r-- | src/dbus/qdbusxmlgenerator.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dbus/qdbusxmlgenerator.cpp b/src/dbus/qdbusxmlgenerator.cpp index 9b888f39bc..e342d5c2b5 100644 --- a/src/dbus/qdbusxmlgenerator.cpp +++ b/src/dbus/qdbusxmlgenerator.cpp @@ -172,7 +172,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method continue; // invalid form if (isSignal && inputCount + 1 != types.count()) continue; // signal with output arguments? - if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message) + if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message()) continue; // signal with QDBusMessage argument? if (isSignal && mm.attributes() & QMetaMethod::Cloned) continue; // cloned signal? @@ -181,7 +181,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method bool isScriptable = mm.attributes() & QMetaMethod::Scriptable; for (j = 1; j < types.count(); ++j) { // input parameter for a slot or output for a signal - if (types.at(j) == QDBusMetaTypeId::message) { + if (types.at(j) == QDBusMetaTypeId::message()) { isScriptable = true; continue; } |