When I run the following code then both slots are called:
auto packet = new Packet(this);
connect(packet, &Packet::packetFinished, this, [packet]()
{
qDebug() << "Slot 1 called.";
packet->deleteLater();
});
connect(packet, &Packet::packetFinished, this, [packet]()
{
qDebug() << "Slot 2 called.";
});
emit packet->packetFinished();
Results in:
"Slot 1 called"
"Slot 2 called"
Is deleteLater()
always executed after all pending slots for a given signal have been called?
Regards,
According to
deleteLater()
documentation.So,
deleteLater()
is called right away, but the object is not deleted at that point. If there is an event loop, and there is no event after the slots being called, then the object will be deleted.