Skip to content

Commit 1ca1ffc

Browse files
authored
fix: Remove reading from replay leading to crash (#142)
1 parent 8419577 commit 1ca1ffc

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

llmcore/RequestHandler.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,24 @@ void RequestHandler::sendLLMRequest(const LLMConfig &config, const QJsonObject &
5454
connect(reply, &QNetworkReply::readyRead, this, [this, reply, request, config]() {
5555
handleLLMResponse(reply, request, config);
5656
});
57-
connect(reply, &QNetworkReply::finished, this, [manager]() { manager->deleteLater(); });
5857

59-
connect(reply, &QNetworkReply::finished, this, [this, reply, requestId]() {
60-
reply->deleteLater();
58+
connect(reply, &QNetworkReply::finished, this, [this, reply, requestId, manager]() {
6159
m_activeRequests.remove(requestId);
6260
if (reply->error() != QNetworkReply::NoError) {
63-
LOG_MESSAGE(QString("Error details: %1\nStatus code: %2\nResponse: %3")
64-
.arg(reply->errorString())
65-
.arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt())
66-
.arg(QString(reply->readAll())));
67-
emit requestFinished(requestId, false, reply->errorString());
61+
QString errorMessage = reply->errorString();
62+
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
63+
64+
LOG_MESSAGE(
65+
QString("Error details: %1\nStatus code: %2").arg(errorMessage).arg(statusCode));
66+
67+
emit requestFinished(requestId, false, errorMessage);
6868
} else {
6969
LOG_MESSAGE("Request finished successfully");
7070
emit requestFinished(requestId, true, QString());
7171
}
72+
73+
reply->deleteLater();
74+
manager->deleteLater();
7275
});
7376
}
7477

0 commit comments

Comments
 (0)