QObject: fix valgrind warning when disconnecting
QObjectPrivate::Connection::method should never be called when the Connection was made with the function pointer syntax This caused valgrind warning about using uninitialized value on such code: QObject::connect(&o, &Object::aSignal, &o, &Object::aSlot); o.disconnect(&o, SLOT(aSlot())); Change-Id: Iaff9ecd3ddfe665db92726b420021493453c4cea Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6f1299c0b4
commit
3750c677ee
@ -3309,7 +3309,7 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c,
|
|||||||
while (c) {
|
while (c) {
|
||||||
if (c->receiver
|
if (c->receiver
|
||||||
&& (receiver == 0 || (c->receiver == receiver
|
&& (receiver == 0 || (c->receiver == receiver
|
||||||
&& (method_index < 0 || c->method() == method_index)
|
&& (method_index < 0 || (!c->isSlotObject && c->method() == method_index))
|
||||||
&& (slot == 0 || (c->isSlotObject && c->slotObj->compare(slot)))))) {
|
&& (slot == 0 || (c->isSlotObject && c->slotObj->compare(slot)))))) {
|
||||||
bool needToUnlock = false;
|
bool needToUnlock = false;
|
||||||
QMutex *receiverMutex = 0;
|
QMutex *receiverMutex = 0;
|
||||||
@ -3999,6 +3999,11 @@ void QObject::dumpObjectInfo()
|
|||||||
c = c->nextConnectionList;
|
c = c->nextConnectionList;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (c->isSlotObject) {
|
||||||
|
qDebug(" <functor or function pointer>");
|
||||||
|
c = c->nextConnectionList;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const QMetaObject *receiverMetaObject = c->receiver->metaObject();
|
const QMetaObject *receiverMetaObject = c->receiver->metaObject();
|
||||||
const QMetaMethod method = receiverMetaObject->method(c->method());
|
const QMetaMethod method = receiverMetaObject->method(c->method());
|
||||||
qDebug(" --> %s::%s %s",
|
qDebug(" --> %s::%s %s",
|
||||||
@ -4017,11 +4022,15 @@ void QObject::dumpObjectInfo()
|
|||||||
|
|
||||||
if (d->senders) {
|
if (d->senders) {
|
||||||
for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) {
|
for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) {
|
||||||
const QMetaMethod slot = metaObject()->method(s->method());
|
QByteArray slotName = QByteArrayLiteral("<unknown>");
|
||||||
qDebug(" <-- %s::%s %s",
|
if (!s->isSlotObject) {
|
||||||
|
const QMetaMethod slot = metaObject()->method(s->method());
|
||||||
|
slotName = slot.methodSignature();
|
||||||
|
}
|
||||||
|
qDebug(" <-- %s::%s %s",
|
||||||
s->sender->metaObject()->className(),
|
s->sender->metaObject()->className(),
|
||||||
s->sender->objectName().isEmpty() ? "unnamed" : qPrintable(s->sender->objectName()),
|
s->sender->objectName().isEmpty() ? "unnamed" : qPrintable(s->sender->objectName()),
|
||||||
slot.methodSignature().constData());
|
slotName.constData());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug(" <None>");
|
qDebug(" <None>");
|
||||||
|
@ -149,7 +149,7 @@ public:
|
|||||||
//ref_ is 2 for the use in the internal lists, and for the use in QMetaObject::Connection
|
//ref_ is 2 for the use in the internal lists, and for the use in QMetaObject::Connection
|
||||||
}
|
}
|
||||||
~Connection();
|
~Connection();
|
||||||
int method() const { return method_offset + method_relative; }
|
int method() const { Q_ASSERT(!isSlotObject); return method_offset + method_relative; }
|
||||||
void ref() { ref_.ref(); }
|
void ref() { ref_.ref(); }
|
||||||
void deref() {
|
void deref() {
|
||||||
if (!ref_.deref()) {
|
if (!ref_.deref()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user