harden(net): ApiCall onFinished reply 快照防御 + 构造 Q_ASSERT(reply)(评审 H3/L1)
This commit is contained in:
parent
8f94443323
commit
f74d47e62e
|
|
@ -6,13 +6,16 @@
|
|||
namespace geopro::net {
|
||||
|
||||
ApiCall::ApiCall(QNetworkReply* reply, QObject* parent) : IApiCall(parent), reply_(reply) {
|
||||
Q_ASSERT(reply); // 契约:不接受 null reply(NAM get/post 正常不返回 null)
|
||||
QObject::connect(reply_, &QNetworkReply::finished, this, &ApiCall::onFinished);
|
||||
}
|
||||
|
||||
void ApiCall::onFinished() {
|
||||
if (aborted_) return; // §5.0 入口守卫:迟到信号闸门
|
||||
ApiResponse resp = buildResponse(reply_);
|
||||
if (reply_) reply_->deleteLater();
|
||||
QNetworkReply* reply = reply_.data(); // 快照:意图明确 + 防御 reply_ 中途被置空
|
||||
if (!reply) return;
|
||||
ApiResponse resp = buildResponse(reply);
|
||||
reply->deleteLater();
|
||||
emit finished(resp);
|
||||
deleteLater();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue