Queue callback for items returning no new future was never called leaving
queue alive and leading to memory leak in Qt client.
{
assert(!myQueue.isEmpty());
- auto next = myQueue.dequeue();
- myNextErrorHandler = next.second;
- myFutureWatcher.setFuture((next.first)(response));
+ RpcResponseFuture const oldFuture = myFutureWatcher.future();
+
+ while (true)
+ {
+ auto next = myQueue.dequeue();
+ myNextErrorHandler = next.second;
+ myFutureWatcher.setFuture((next.first)(response));
+
+ if (oldFuture != myFutureWatcher.future())
+ {
+ break;
+ }
+
+ if (myQueue.isEmpty())
+ {
+ deleteLater();
+ break;
+ }
+ }
}
void RpcQueue::run()
d->show();
});
- q->add([this, addMe, trashOriginal](RpcResponse const& r)
+ q->add([this, addMe](RpcResponse const& r)
{
tr_variant* dup;
char const* str;
connect(d, SIGNAL(rejected()), d, SLOT(deleteLater()));
d->show();
}
- else if (trashOriginal && addMe.type == AddData::FILENAME)
+ });
+
+ if (trashOriginal && addMe.type == AddData::FILENAME)
+ {
+ q->add([this, addMe]()
{
QFile original(addMe.filename);
original.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
original.remove();
- }
- });
+ });
+ }
q->run();
}