@@ -317,6 +317,8 @@ private Q_SLOTS:
317
317
void getAndThenDeleteObject_data ();
318
318
void getAndThenDeleteObject ();
319
319
320
+ void deleteManagerWhileGetIsInProgress ();
321
+
320
322
void symbianOpenCDataUrlCrash ();
321
323
322
324
void qtbug12908compressedHttpReply ();
@@ -5109,6 +5111,48 @@ void tst_QNetworkReply::getAndThenDeleteObject()
5109
5111
}
5110
5112
}
5111
5113
5114
+ void tst_QNetworkReply::deleteManagerWhileGetIsInProgress ()
5115
+ {
5116
+ // yes, this will leak if the testcase fails. I don't care. It must not fail then :P
5117
+ QNetworkAccessManager *manager = new QNetworkAccessManager ();
5118
+ QNetworkRequest request (" http://" + QtNetworkSettings::serverName () + " /qtest/bigfile" );
5119
+ QNetworkReply *reply = manager->get (request);
5120
+ reply->setReadBufferSize (1024 );
5121
+
5122
+ // Reset reply's parent to allow it to outlive the manager
5123
+ reply->setParent (0 );
5124
+
5125
+ // Wait until a buffer is received
5126
+ int totalWait = 0 ;
5127
+ while (!reply->bytesAvailable ()) {
5128
+ QTest::qWait (20 );
5129
+ totalWait += 20 ;
5130
+ QVERIFY ( totalWait <= 5 *1000 );
5131
+ }
5132
+
5133
+ QVERIFY (reply->bytesAvailable ());
5134
+ QCOMPARE (reply->attribute (QNetworkRequest::HttpStatusCodeAttribute).toInt (), 200 );
5135
+ QVERIFY (!reply->isFinished ()); // must not be finished
5136
+
5137
+ // Read the data to request next buffer's worth from the server
5138
+ (void )reply->readAll ();
5139
+
5140
+ QSignalSpy replyFinishedSpy (reply, SIGNAL (finished ()));
5141
+
5142
+ // Delete the manager
5143
+ delete manager;
5144
+ manager = 0 ;
5145
+
5146
+ // Wait to allow reply to process any pending events
5147
+ QTest::qWait (100 );
5148
+
5149
+ // The reply should be finished
5150
+ QVERIFY (reply->isFinished ());
5151
+ QCOMPARE (replyFinishedSpy.count (), 1 );
5152
+
5153
+ delete reply;
5154
+ }
5155
+
5112
5156
// see https://bugs.webkit.org/show_bug.cgi?id=38935
5113
5157
void tst_QNetworkReply::symbianOpenCDataUrlCrash ()
5114
5158
{
0 commit comments