@@ -74,6 +74,8 @@ void PropConditions::updateDxTrends()
74
74
FCT_IDENTIFICATION;
75
75
76
76
dxTrendResult.clear ();
77
+ dxTrendTimeoutTimer.stop ();
78
+ dxTrendPendingConnections.clear (); // pending connections will be ignored.
77
79
78
80
for ( const QString& continent : Data::getContinentList () )
79
81
dxTrendPendingConnections << nam->get (prepareRequest (QUrl (DXC_TRENDS + QString (" /%0/15" ).arg (continent))));
@@ -209,9 +211,9 @@ void PropConditions::processReply(QNetworkReply* reply)
209
211
emit mufMapUpdated ();
210
212
}
211
213
}
212
- else if ( replyURL. toString (). contains (DXC_TRENDS ) )
214
+ else if ( dxTrendPendingConnections. contains (reply ) )
213
215
{
214
- dxTrendPendingConnections.removeAll (reply);
216
+ dxTrendPendingConnections.remove (reply);
215
217
216
218
QJsonDocument doc = QJsonDocument::fromJson (data);
217
219
const QString &requestContinent = replyURL.path ().section (' /' , -2 , -2 );
@@ -247,7 +249,7 @@ void PropConditions::processReply(QNetworkReply* reply)
247
249
else
248
250
{
249
251
qCDebug (runtime) << " HTTP Status Code" << replyStatusCode;
250
- dxTrendPendingConnections.removeAll (reply);
252
+ dxTrendPendingConnections.remove (reply);
251
253
repeateRequest (reply->url ());
252
254
reply->deleteLater ();
253
255
}
@@ -267,7 +269,10 @@ void PropConditions::repeateRequest(const QUrl &url)
267
269
QTimer::singleShot (1000 * RESEND_BASE_INTERVAL * failedRequests[url], this , [this , url]()
268
270
{
269
271
qCDebug (runtime) << " Resending request" << url.toString ();
270
- nam->get (prepareRequest (url));
272
+ QNetworkReply *req = nam->get (prepareRequest (url));
273
+ if ( url.toString ().contains (DXC_TRENDS))
274
+ dxTrendPendingConnections << req;
275
+
271
276
});
272
277
}
273
278
else
@@ -291,18 +296,24 @@ void PropConditions::dxTrendTimeout()
291
296
292
297
dxTrendTimeoutTimer.stop ();
293
298
294
- for ( auto it = dxTrendPendingConnections.begin (); it != dxTrendPendingConnections.end (); ++it )
299
+ for ( auto it = dxTrendPendingConnections.begin (); it != dxTrendPendingConnections.end (); )
295
300
{
296
- (*it)->abort ();
297
- (*it)->deleteLater ();
301
+ QNetworkReply* reply = *it;
302
+ it = dxTrendPendingConnections.erase (it);
303
+ if ( reply )
304
+ {
305
+ reply->abort ();
306
+ reply->deleteLater ();
307
+ }
298
308
}
309
+
310
+ dxTrendPendingConnections.clear ();
299
311
dxTrendResult.clear ();
300
312
emit dxTrendFinalized (dxTrendResult); // emit empty result
301
313
}
302
314
303
315
PropConditions::~PropConditions ()
304
316
{
305
- dxTrendTimeoutTimer.stop ();
306
317
dxTrendTimeout ();
307
318
nam->deleteLater ();
308
319
}
0 commit comments