summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2017-02-15 16:35:07 +0100
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2017-02-22 07:37:51 +0000
commit5426e689f9d7d5e5e6e1a877578f17c96d248fdd (patch)
tree847c8b75bcaa0228254b76e0c9699f559bc2cb17
parent7de8745eaae6777819824cffd40a842fa0dd377b (diff)
Fix a race condition between QObject::connect and qRegisterMetaType
QObject::connect will extract the QArgumentType for first the signal, then the slot. The QArgumentType with a string constructor will query the metatype system to get the meta type id. But it might happen that between the extraction of the signal's argument and the slot's argument, qRegisterMetaType was called in another thread. For this reason, it's possible that one QArgumentType has a type id while the other does not. For this reason, we should fall back to compare the string if any of the argument's type is 0. Task-number: QTBUG-50901 Change-Id: I260ca662ff00a773ae519f78bb633e05fde0ea81 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/kernel/qmetaobject_p.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 1c540f64c7..e247c48703 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -143,21 +143,17 @@ public:
}
bool operator==(const QArgumentType &other) const
{
- if (_type)
+ if (_type && other._type)
return _type == other._type;
- else if (other._type)
- return false;
else
- return _name == other._name;
+ return name() == other.name();
}
bool operator!=(const QArgumentType &other) const
{
- if (_type)
+ if (_type && other._type)
return _type != other._type;
- else if (other._type)
- return true;
else
- return _name != other._name;
+ return name() != other.name();
}
private: