fix a couple of bugs in SendQueue

This commit is contained in:
Stephen Birarda 2015-07-30 17:17:03 -07:00
parent 0f1d1a16a7
commit 1724e3c632

View file

@ -62,7 +62,9 @@ void SendQueue::run() {
// We need to make sure this is called on the right thread
if (thread() != QThread::currentThread()) {
QMetaObject::invokeMethod(this, "run", Qt::QueuedConnection);
return;
}
_isRunning = true;
// This will loop and sleep to send packets
@ -161,12 +163,13 @@ void SendQueue::loop() {
}
// If there is no packet to resend, grab the next one in the list
if (!nextPacket) {
if (!nextPacket && _packets.size() > 0) {
QWriteLocker locker(&_packetsLock);
nextPacket.swap(_packets.front());
_packets.pop_front();
}
if (nextPacket) {
bool shouldSendSecondOfPair = false;
if (!hasResend) {
@ -217,6 +220,9 @@ void SendQueue::loop() {
}
}
}
// since we're a while loop, give the thread a chance to process events
QCoreApplication::processEvents();