Skip to content

Commit

Permalink
qdeclarativexmlhttprequest: Stabilize, ensure deletion of server.
Browse files Browse the repository at this point in the history
Introduce QScopedPointer to make sure the server is also deleted in
case the test fails thus suppressing follow-up errors caused by
the port still being in use by a leaked server.

Change-Id: I9fd8a96ea5aba42487df8f22bc9a79917b9d8c16
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
  • Loading branch information
Friedemann Kleint authored and Qt by Nokia committed Dec 20, 2011
1 parent 9697e2a commit d009638
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -43,6 +43,7 @@
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDebug>
#include <QScopedPointer>
#include <QNetworkCookieJar>
#include "testhttpserver.h"
#include "../../shared/util.h"
Expand Down Expand Up @@ -254,9 +255,9 @@ void tst_qdeclarativexmlhttprequest::open()
QFETCH(QString, url);
QFETCH(bool, remote);

TestHTTPServer *server = 0;
QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
if (remote) {
server = new TestHTTPServer(SERVER_PORT);
server.reset(new TestHTTPServer(SERVER_PORT));
QVERIFY(server->isValid());
QVERIFY(server->wait(TEST_FILE("open_network.expect"),
TEST_FILE("open_network.reply"),
Expand All @@ -278,7 +279,6 @@ void tst_qdeclarativexmlhttprequest::open()

QTRY_VERIFY(object->property("dataOK").toBool() == true);

delete server;
delete object;
}

Expand Down

0 comments on commit d009638

Please sign in to comment.