diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-21 17:25:16 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-08-21 17:32:48 (GMT) |
commit | c302d6206dfc6169abdc524c5729dd4065b0e27c (patch) | |
tree | 0e74792e8c1bc36e833b1ed2f35f434812e1d290 /src | |
parent | f0289430822c241f808c64342ae796ba6a460096 (diff) | |
download | Qt-c302d6206dfc6169abdc524c5729dd4065b0e27c.zip Qt-c302d6206dfc6169abdc524c5729dd4065b0e27c.tar.gz Qt-c302d6206dfc6169abdc524c5729dd4065b0e27c.tar.bz2 |
QMetaObject: Crashes with dbus that tries to connect to all signals
The compatibility method QMetaObject::connect did not handle the
signal_index = -1 to connect to all signal
Reviewed-by: Thiago
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 040efc9..2117a2d 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2981,12 +2981,16 @@ void QObject::disconnectNotify(const char *) bool QMetaObject::connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type, int *types) { - const QMetaObject *mo = sender->metaObject(); - while (mo && mo->methodOffset() > signal_index) - mo = mo->superClass(); - int signalOffset, methodOffset; - computeOffsets(mo, &signalOffset, &methodOffset); - signal_index = QMetaObjectPrivate::originalClone(mo, signal_index - methodOffset) + signalOffset; + if (signal_index > 0) { + const QMetaObject *mo = sender->metaObject(); + while (mo && mo->methodOffset() > signal_index) + mo = mo->superClass(); + if (mo) { + int signalOffset, methodOffset; + computeOffsets(mo, &signalOffset, &methodOffset); + signal_index = QMetaObjectPrivate::originalClone(mo, signal_index - methodOffset) + signalOffset; + } + } return QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types); } @@ -3059,12 +3063,16 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index, bool QMetaObject::disconnect(const QObject *sender, int signal_index, const QObject *receiver, int method_index) { - const QMetaObject *mo = sender->metaObject(); - while (mo && mo->methodOffset() > signal_index) - mo = mo->superClass(); - int signalOffset, methodOffset; - computeOffsets(mo, &signalOffset, &methodOffset); - signal_index = QMetaObjectPrivate::originalClone(mo, signal_index - methodOffset) + signalOffset; + if (signal_index > 0) { + const QMetaObject *mo = sender->metaObject(); + while (mo && mo->methodOffset() > signal_index) + mo = mo->superClass(); + if (mo) { + int signalOffset, methodOffset; + computeOffsets(mo, &signalOffset, &methodOffset); + signal_index = QMetaObjectPrivate::originalClone(mo, signal_index - methodOffset) + signalOffset; + } + } return QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index); } |