From 5426e689f9d7d5e5e6e1a877578f17c96d248fdd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 15 Feb 2017 16:35:07 +0100 Subject: 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 Reviewed-by: Marc Mutz Reviewed-by: Jesus Fernandez Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetaobject_p.h | 12 ++++-------- 1 file 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: -- cgit v1.2.3