delete unused pointers
This commit is contained in:
parent
2ed294ea4c
commit
e196e57a04
@ -45,6 +45,7 @@ void hotkeying::clearAll() {
|
|||||||
for(QString e : hotkeys.keys()) {
|
for(QString e : hotkeys.keys()) {
|
||||||
QHotkey *hk = hotkeys.value(e);
|
QHotkey *hk = hotkeys.value(e);
|
||||||
hk->setRegistered(false);
|
hk->setRegistered(false);
|
||||||
|
delete hk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <thread>
|
|
||||||
#include <logs/requestlogging.hpp>
|
#include <logs/requestlogging.hpp>
|
||||||
#include <logs/screenshotfile.h>
|
#include <logs/screenshotfile.h>
|
||||||
|
|
||||||
QNetworkAccessManager ioutils::networkManager;
|
QNetworkAccessManager* ioutils::networkManager= new QNetworkAccessManager();
|
||||||
|
|
||||||
void ioutils::addLogEntry(QNetworkReply* reply, QByteArray data, QString result, ScreenshotFile sf) {
|
void ioutils::addLogEntry(QNetworkReply* reply, QByteArray data, QString result, ScreenshotFile sf) {
|
||||||
requestlogging::RequestContext ctx;
|
requestlogging::RequestContext ctx;
|
||||||
@ -38,13 +37,13 @@ void ioutils::postMultipart(QUrl target,
|
|||||||
for (auto header : headers) {
|
for (auto header : headers) {
|
||||||
if (header.first.toLower() != "content-type") req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
if (header.first.toLower() != "content-type") req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.post(req, body);
|
QNetworkReply *reply = networkManager->post(req, body);
|
||||||
addTask();
|
addTask();
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
||||||
removeTask();
|
removeTask();
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
callback(QJsonDocument::fromJson(data), data, reply);
|
callback(QJsonDocument::fromJson(data), data, reply);
|
||||||
delete reply;
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +55,13 @@ void ioutils::postMultipartData(QUrl target,
|
|||||||
for (auto header : headers) {
|
for (auto header : headers) {
|
||||||
if (header.first.toLower() != "content-type") req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
if (header.first.toLower() != "content-type") req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.post(req, body);
|
QNetworkReply *reply = networkManager->post(req, body);
|
||||||
addTask();
|
addTask();
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
||||||
removeTask();
|
removeTask();
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
callback(data, reply);
|
callback(data, reply);
|
||||||
delete reply;
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ void ioutils::getJson(QUrl target,
|
|||||||
for (auto header : headers) {
|
for (auto header : headers) {
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.get(req);
|
QNetworkReply *reply = networkManager->get(req);
|
||||||
addTask();
|
addTask();
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
||||||
removeTask();
|
removeTask();
|
||||||
@ -91,13 +90,13 @@ void ioutils::postJson(QUrl target,
|
|||||||
for (auto header : headers) {
|
for (auto header : headers) {
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.post(req, body);
|
QNetworkReply *reply = networkManager->post(req, body);
|
||||||
addTask();
|
addTask();
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
||||||
removeTask();
|
removeTask();
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
callback(QJsonDocument::fromJson(data), data, reply);
|
callback(QJsonDocument::fromJson(data), data, reply);
|
||||||
delete reply;
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,13 +105,13 @@ void ioutils::getData(QUrl target, QList<QPair<QString, QString>> headers, std::
|
|||||||
for (auto header : headers) {
|
for (auto header : headers) {
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.get(req);
|
QNetworkReply *reply = networkManager->get(req);
|
||||||
addTask();
|
addTask();
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
||||||
removeTask();
|
removeTask();
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
callback(data, reply);
|
callback(data, reply);
|
||||||
delete reply;
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,16 +123,19 @@ void ioutils::postData(QUrl target,
|
|||||||
for (auto header : headers) {
|
for (auto header : headers) {
|
||||||
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
req.setRawHeader(header.first.toUtf8(), header.second.toUtf8());
|
||||||
}
|
}
|
||||||
QNetworkReply *reply = networkManager.post(req, body);
|
QNetworkReply *reply = networkManager->post(req, body);
|
||||||
addTask();
|
addTask();
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
QObject::connect(reply, &QNetworkReply::finished, [reply, callback] {
|
||||||
removeTask();
|
removeTask();
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
callback(data, reply);
|
callback(data, reply);
|
||||||
delete reply;
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ioutils::deleteNetworkManger() {
|
||||||
|
delete networkManager;
|
||||||
|
}
|
||||||
|
|
||||||
QString ioutils::methodString(QNetworkAccessManager::Operation operation) {
|
QString ioutils::methodString(QNetworkAccessManager::Operation operation) {
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <logs/screenshotfile.h>
|
#include <logs/screenshotfile.h>
|
||||||
|
|
||||||
namespace ioutils {
|
namespace ioutils {
|
||||||
extern QNetworkAccessManager networkManager;
|
extern QNetworkAccessManager* networkManager;
|
||||||
void addLogEntry(QNetworkReply* reply, QByteArray data, QString result, ScreenshotFile sf);
|
void addLogEntry(QNetworkReply* reply, QByteArray data, QString result, ScreenshotFile sf);
|
||||||
void getJson(QUrl target,
|
void getJson(QUrl target,
|
||||||
QList<QPair<QString, QString>> headers,
|
QList<QPair<QString, QString>> headers,
|
||||||
@ -28,6 +28,7 @@ namespace ioutils {
|
|||||||
QList<QPair<QString, QString>> headers,
|
QList<QPair<QString, QString>> headers,
|
||||||
QHttpMultiPart *body,
|
QHttpMultiPart *body,
|
||||||
std::function<void(QByteArray, QNetworkReply *)> callback);
|
std::function<void(QByteArray, QNetworkReply *)> callback);
|
||||||
|
void deleteNetworkManger();
|
||||||
QString methodString(QNetworkAccessManager::Operation operation);
|
QString methodString(QNetworkAccessManager::Operation operation);
|
||||||
QString httpString(int responseCode);
|
QString httpString(int responseCode);
|
||||||
} // namespace ioutils
|
} // namespace ioutils
|
||||||
|
@ -205,6 +205,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::quit() {
|
void MainWindow::quit() {
|
||||||
|
ioutils::deleteNetworkManger();
|
||||||
hotkeying::clearAll();
|
hotkeying::clearAll();
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user