Add some asserts to closure.
This commit is contained in:
parent
a6e8797b9d
commit
5e343611bf
@ -32,19 +32,25 @@ Closure::Closure(QObject* sender,
|
||||
const QMetaObject* meta_receiver = receiver->metaObject();
|
||||
|
||||
QByteArray normalised_slot = QMetaObject::normalizedSignature(slot + 1);
|
||||
slot_ = meta_receiver->method(
|
||||
meta_receiver->indexOfSlot(normalised_slot.constData()));
|
||||
const int index = meta_receiver->indexOfSlot(normalised_slot.constData());
|
||||
Q_ASSERT(index != -1);
|
||||
slot_ = meta_receiver->method(index);
|
||||
|
||||
connect(sender, signal, SLOT(Invoked()));
|
||||
connect(sender, SIGNAL(destroyed()), SLOT(Cleanup()));
|
||||
Connect(sender, signal);
|
||||
}
|
||||
|
||||
Closure::Closure(QObject* sender,
|
||||
const char* signal,
|
||||
std::tr1::function<void()> callback)
|
||||
: callback_(callback) {
|
||||
connect(sender, signal, SLOT(Invoked()));
|
||||
connect(sender, SIGNAL(destroyed()), SLOT(Cleanup()));
|
||||
Connect(sender, signal);
|
||||
}
|
||||
|
||||
void Closure::Connect(QObject* sender, const char* signal) {
|
||||
bool success = connect(sender, signal, SLOT(Invoked()));
|
||||
Q_ASSERT(success);
|
||||
success = connect(sender, SIGNAL(destroyed()), SLOT(Cleanup()));
|
||||
Q_ASSERT(success);
|
||||
}
|
||||
|
||||
void Closure::Invoked() {
|
||||
|
@ -64,6 +64,8 @@ class Closure : public QObject {
|
||||
void Cleanup();
|
||||
|
||||
private:
|
||||
void Connect(QObject* sender, const char* signal);
|
||||
|
||||
QMetaMethod slot_;
|
||||
std::tr1::function<void()> callback_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user