mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed crash related to concurrent network request
This commit is contained in:
parent
eb38b53c04
commit
bdb82b6818
|
@ -4,10 +4,12 @@
|
||||||
#include "common/NetworkManager.hpp"
|
#include "common/NetworkManager.hpp"
|
||||||
#include "common/Outcome.hpp"
|
#include "common/Outcome.hpp"
|
||||||
#include "common/Version.hpp"
|
#include "common/Version.hpp"
|
||||||
|
#include "debug/AssertInGuiThread.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "util/DebugCount.hpp"
|
#include "util/DebugCount.hpp"
|
||||||
|
#include "util/PostToThread.hpp"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
@ -315,13 +317,27 @@ void NetworkRequest::doRequest()
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
QObject::connect(reply, &QNetworkReply::finished, worker,
|
|
||||||
[handleReply, worker]() mutable {
|
|
||||||
handleReply();
|
|
||||||
|
|
||||||
delete worker;
|
// auto
|
||||||
});
|
|
||||||
// }
|
QObject::connect(
|
||||||
|
reply, &QNetworkReply::finished, worker,
|
||||||
|
[data, handleReply, worker]() mutable {
|
||||||
|
if (data->executeConcurrently || isGuiThread())
|
||||||
|
{
|
||||||
|
handleReply();
|
||||||
|
|
||||||
|
delete worker;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
postToThread(
|
||||||
|
[worker, cb = std::move(handleReply)]() mutable {
|
||||||
|
cb();
|
||||||
|
delete worker;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
QObject::connect(&requester, &NetworkRequester::requestUrl, worker,
|
QObject::connect(&requester, &NetworkRequester::requestUrl, worker,
|
||||||
|
|
Loading…
Reference in a new issue