X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fsignalproxy.cpp;h=19b9af83e2f36c485947527fb86c609349b530b6;hp=1d8c956daf4e92a9e1013f05a73c212e85ac7f31;hb=4ce53949ab7d52a49ae79b8817bd3aa50fada0d1;hpb=78b37c1a0610d9a4fb26ba0dec7337d6f7960041 diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index 1d8c956d..19b9af83 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -96,11 +96,7 @@ void SignalProxy::SignalRelay::attachSignal(QObject *sender, int signalId, const } else { fn = SIGNAL(fakeMethodSignature()); -#if QT_VERSION >= 0x050000 fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).methodSignature()); -#else - fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).signature()); -#endif } _slots[slotId] = Signal(sender, signalId, fn); @@ -145,11 +141,7 @@ int SignalProxy::SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void ** const QList &argTypes = eMeta->argTypes(signal.signalId); for (int i = 0; i < argTypes.size(); i++) { if (argTypes[i] == 0) { -#if QT_VERSION >= 0x050000 qWarning() << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(signal.signalId).methodSignature().constData()); -#else - qWarning() << "SignalRelay::qt_metacall(): received invalid data for argument number" << i << "of signal" << QString("%1::%2").arg(caller->metaObject()->className()).arg(caller->metaObject()->method(signal.signalId).signature()); -#endif qWarning() << " - make sure all your data types are known by the Qt MetaSystem"; return _id; } @@ -475,8 +467,11 @@ void SignalProxy::synchronize(SyncableObject *obj) void SignalProxy::detachObject(QObject *obj) { - detachSignals(obj); - detachSlots(obj); + // Don't try to connect SignalProxy from itself on shutdown + if (obj != this) { + detachSignals(obj); + detachSlots(obj); + } } @@ -666,11 +661,7 @@ bool SignalProxy::invokeSlot(QObject *receiver, int methodId, const QVariantList // check for argument compatibility and build params array for (int i = 0; i < numArgs; i++) { if (!params[i].isValid()) { -#if QT_VERSION >= 0x050000 qWarning() << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).methodSignature().constData()); -#else - qWarning() << "SignalProxy::invokeSlot(): received invalid data for argument number" << i << "of method" << QString("%1::%2()").arg(receiver->metaObject()->className()).arg(receiver->metaObject()->method(methodId).signature()); -#endif qWarning() << " - make sure all your data types are known by the Qt MetaSystem"; return false; } @@ -829,7 +820,7 @@ void SignalProxy::updateSecureState() QVariantList SignalProxy::peerData() { QVariantList result; - for (auto peer : _peerMap.values()) { + for (auto &&peer : _peerMap.values()) { QVariantMap data; data["id"] = peer->id(); data["clientVersion"] = peer->clientVersion(); @@ -839,15 +830,18 @@ QVariantList SignalProxy::peerData() { data["remoteAddress"] = peer->address(); data["connectedSince"] = peer->connectedSince(); data["secure"] = peer->isSecure(); - int features = peer->features(); - data["features"] = features; + data["features"] = static_cast(peer->features().toLegacyFeatures()); + data["featureList"] = peer->features().toStringList(); result << data; } return result; } Peer *SignalProxy::peerById(int peerId) { - return _peerMap[peerId]; + // We use ::value() here instead of the [] operator because the latter has the side-effect + // of automatically inserting a null value with the passed key into the map. See + // https://doc.qt.io/qt-5/qhash.html#operator-5b-5d and https://doc.qt.io/qt-5/qhash.html#value. + return _peerMap.value(peerId); } void SignalProxy::restrictTargetPeers(QSet peers, std::function closure) @@ -890,11 +884,7 @@ SignalProxy::ExtendedMetaObject::ExtendedMetaObject(const QMetaObject *meta, boo if (_meta->method(i).methodType() != QMetaMethod::Slot) continue; -#if QT_VERSION >= 0x050000 if (_meta->method(i).methodSignature().contains('*')) -#else - if (QByteArray(_meta->method(i).signature()).contains('*')) -#endif continue; // skip methods with ptr params QByteArray method = methodName(_meta->method(i)); @@ -923,11 +913,7 @@ SignalProxy::ExtendedMetaObject::ExtendedMetaObject(const QMetaObject *meta, boo } if (checkConflicts) { qWarning() << "class" << meta->className() << "contains overloaded methods which is currently not supported!"; -#if QT_VERSION >= 0x050000 qWarning() << " - " << _meta->method(i).methodSignature() << "conflicts with" << _meta->method(_methodIds[method]).methodSignature(); -#else - qWarning() << " - " << _meta->method(i).signature() << "conflicts with" << _meta->method(_methodIds[method]).signature(); -#endif } continue; } @@ -967,11 +953,7 @@ const QHash &SignalProxy::ExtendedMetaObject::receiveMap() if (QMetaType::Void == (QMetaType::Type)returnType(i)) continue; -#if QT_VERSION >= 0x050000 signature = requestSlot.methodSignature(); -#else - signature = QByteArray(requestSlot.signature()); -#endif if (!signature.startsWith("request")) continue; @@ -1005,22 +987,14 @@ const QHash &SignalProxy::ExtendedMetaObject::receiveMap() QByteArray SignalProxy::ExtendedMetaObject::methodName(const QMetaMethod &method) { -#if QT_VERSION >= 0x050000 QByteArray sig(method.methodSignature()); -#else - QByteArray sig(method.signature()); -#endif return sig.left(sig.indexOf("(")); } QString SignalProxy::ExtendedMetaObject::methodBaseName(const QMetaMethod &method) { -#if QT_VERSION >= 0x050000 QString methodname = QString(method.methodSignature()).section("(", 0, 0); -#else - QString methodname = QString(method.signature()).section("(", 0, 0); -#endif // determine where we have to chop: int upperCharPos; @@ -1058,11 +1032,7 @@ SignalProxy::ExtendedMetaObject::MethodDescriptor::MethodDescriptor(const QMetaM _argTypes = argTypes; // determine minArgCount -#if QT_VERSION >= 0x050000 QString signature(method.methodSignature()); -#else - QString signature(method.signature()); -#endif _minArgCount = method.parameterTypes().count() - signature.count("="); _receiverMode = (_methodName.startsWith("request"))