Replay: make response a const reference in parseResponse (#20787)

albatross
Dean Lee 2021-05-02 00:50:32 +08:00 committed by GitHub
parent ad57cd3759
commit 228308b719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -10,12 +10,11 @@ Replay::Replay(QString route_, int seek) : route(route_) {
#endif #endif
http = new HttpRequest(this, "https://api.commadotai.com/v1/route/" + route + "/files", "", create_jwt); http = new HttpRequest(this, "https://api.commadotai.com/v1/route/" + route + "/files", "", create_jwt);
QObject::connect(http, SIGNAL(receivedResponse(QString)), this, SLOT(parseResponse(QString))); QObject::connect(http, &HttpRequest::receivedResponse, this, &Replay::parseResponse);
} }
void Replay::parseResponse(QString response){ void Replay::parseResponse(const QString &response){
response = response.trimmed(); QJsonDocument doc = QJsonDocument::fromJson(response.trimmed().toUtf8());
QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8());
if (doc.isNull()) { if (doc.isNull()) {
qDebug() << "JSON Parse failed"; qDebug() << "JSON Parse failed";

View File

@ -29,7 +29,7 @@ public:
QQueue<int> event_sizes; QQueue<int> event_sizes;
public slots: public slots:
void parseResponse(QString response); void parseResponse(const QString &response);
protected: protected:
Unlogger *unlogger; Unlogger *unlogger;