Revert dd538539aa, fix RPC queue processing

Queue callback for items returning no new future was never called leaving
queue alive and leading to memory leak in Qt client.
This commit is contained in:
Mike Gelfand 2017-07-15 08:46:31 +03:00
parent 580c5e4166
commit 375f2642c8
2 changed files with 27 additions and 7 deletions

View File

@ -72,9 +72,25 @@ void RpcQueue::runNext(RpcResponseFuture const& response)
{
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()

View File

@ -995,7 +995,7 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
d->show();
});
q->add([this, addMe, trashOriginal](RpcResponse const& r)
q->add([this, addMe](RpcResponse const& r)
{
tr_variant* dup;
char const* str;
@ -1010,13 +1010,17 @@ void Session::addTorrent(AddData const& addMe, tr_variant* args, bool trashOrigi
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();
}