fix: more carefully use app in NetworkPrivate/NetworkTask (#6698)
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
- Bugfix: Forward query params to websocket URLs. (#6141)
|
||||
- Bugfix: Fixed Lua errors from handlers of HTTP requests not being logged. (#6452)
|
||||
- Bugfix: Fixed restore button not showing on Windows. (#6565)
|
||||
- Bugfix: Fixed a crash that could occur when network requests were loading/saving cache as Chatterino was being shut down. (#6698)
|
||||
- Bugfix: Fixed popups and the overlay not being draggable on Wayland. (#6573)
|
||||
- Bugfix: Fixed middle-clicking usernames in a local channel opening an invalid viewercard. (#6577)
|
||||
- Bugfix: Added `desktop-entry` hint to Linux notifications. (#6615)
|
||||
|
||||
@@ -59,8 +59,24 @@ void loadUncached(std::shared_ptr<NetworkData> &&data)
|
||||
|
||||
void loadCached(std::shared_ptr<NetworkData> &&data)
|
||||
{
|
||||
QFile cachedFile(getApp()->getPaths().cacheDirectory() + "/" +
|
||||
data->getHash());
|
||||
if (isAppAboutToQuit())
|
||||
{
|
||||
qCDebug(chatterinoHTTP)
|
||||
<< "Skipping cached network load " << data->request.url()
|
||||
<< "because app is about to quit";
|
||||
return;
|
||||
}
|
||||
|
||||
auto *app = tryGetApp();
|
||||
if (!app)
|
||||
{
|
||||
qCDebug(chatterinoHTTP)
|
||||
<< "Skipping cached network load " << data->request.url()
|
||||
<< "because app is about to quit";
|
||||
return;
|
||||
}
|
||||
|
||||
QFile cachedFile(app->getPaths().cacheDirectory() + "/" + data->getHash());
|
||||
|
||||
if (!cachedFile.exists() || !cachedFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
|
||||
@@ -141,7 +141,24 @@ void NetworkTask::logReply()
|
||||
void NetworkTask::writeToCache(const QByteArray &bytes) const
|
||||
{
|
||||
std::ignore = QtConcurrent::run([data = this->data_, bytes] {
|
||||
QFile cachedFile(getApp()->getPaths().cacheDirectory() + "/" +
|
||||
if (isAppAboutToQuit())
|
||||
{
|
||||
qCDebug(chatterinoHTTP)
|
||||
<< "Skipping cache write for" << data->request.url()
|
||||
<< "because app is about to quit";
|
||||
return;
|
||||
}
|
||||
|
||||
auto *app = tryGetApp();
|
||||
if (!app)
|
||||
{
|
||||
qCDebug(chatterinoHTTP)
|
||||
<< "Skipping cache write for" << data->request.url()
|
||||
<< "because app is null";
|
||||
return;
|
||||
}
|
||||
|
||||
QFile cachedFile(app->getPaths().cacheDirectory() + "/" +
|
||||
data->getHash());
|
||||
|
||||
if (cachedFile.open(QIODevice::WriteOnly))
|
||||
|
||||
Reference in New Issue
Block a user