[SOLVED]Bridging Signal - Slot connection
-
I'm trying to bride a signal - slot connection over a 3rd object.
Therefor i have implemented a connector class, which uses an id to identify the corresponding participants which registered a signal or slot method:class Participant : public QObject { Q_OBJECT public: explicit Participant(QObject *in_object, QMetaMethod *in_method, QObject *parent = 0) : QObject(parent), m_p_object(in_object), m_p_method(in_method) { } QObject *object() { return m_p_object; } QMetaMethod *method() { return m_p_method; } private: QObject *m_p_object; QMetaMethod *m_p_method; };
bool CheckConnection(int in_type) { Participant *sender = 0, *receiver = 0; if (m_signal_bridge_map.contains(in_type)) { sender = m_signal_bridge_map.value(in_type); if (sender == 0) return false; if (sender->object() == 0) return false; if (sender->method()->isValid() == false) return false; qDebug() << "IConnector::CheckConnection - Sender found ..."; } if (m_remote_slot_map.contains(in_type)) { receiver = m_remote_slot_map.value(in_type); if (receiver == 0) return false; if (receiver->object() == 0) return false; if (receiver->method()->isValid() == false) return false; qDebug() << "IConnector::CheckConnection - Receiver found ..."; } if (sender == 0 || receiver == 0) return false; qDebug() << "IConnector::CheckConnection - connecting" << sender->method()->name() << receiver->method()->name(); return QObject::connect(sender->object(), sender->method()->name(), receiver->object(), receiver->method()->name()); }
When a sender-receiver pair is found, the sender->method()->name() call runs into ASSERT:
Any idea why this wouldn't work?
-
Found the error.
Stored the pointer of a local QMetaMethod object ... * blush *