made caller/concurrent rules tighter

This commit is contained in:
fourtf
2019-08-20 23:29:11 +02:00
parent 7d842e6cf7
commit 14222f84f2
9 changed files with 36 additions and 15 deletions
+17 -2
View File
@@ -125,6 +125,11 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
}
auto handleReply = [data, reply]() mutable {
if (data->hasCaller_ && !data->caller_.get())
{
return;
}
// TODO(pajlada): A reply was received, kill the timeout timer
if (reply->error() != QNetworkReply::NetworkError::NoError)
{
@@ -162,7 +167,6 @@ void loadUncached(const std::shared_ptr<NetworkData> &data)
if (data->executeConcurrently || isGuiThread())
{
handleReply();
delete worker;
}
else
@@ -206,11 +210,22 @@ void loadCached(const std::shared_ptr<NetworkData> &data)
// XXX: If outcome is Failure, we should invalidate the cache file
// somehow/somewhere
/*auto outcome =*/
if (data->hasCaller_ && !data->caller_.get())
{
return;
}
data->onSuccess_(result);
}
else
{
postToThread([data, result]() { data->onSuccess_(result); });
postToThread([data, result]() {
if (data->hasCaller_ && !data->caller_.get())
{
return;
}
data->onSuccess_(result);
});
}
}
} // namespace chatterino