tst_QSslSocket::setLocalCertificateChain(): fix resource leak when test fail

The deleteLater() call wasn't reliably reached when tests fail,
so use a QScopedPointer with QScopedPointerDeleteLater deleter.

Change-Id: Ica73bc73c2a0ac1e9b77e4804f2aedcad9b662a0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Marc Mutz 2016-08-09 13:15:53 +03:00
parent 08a3a52958
commit 3b0ea78603

View File

@ -1390,7 +1390,8 @@ void tst_QSslSocket::setLocalCertificateChain()
QEventLoop loop;
QTimer::singleShot(5000, &loop, SLOT(quit()));
socket = new QSslSocket();
const QScopedPointer<QSslSocket, QScopedPointerDeleteLater> client(new QSslSocket);
socket = client.data();
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
@ -1402,8 +1403,6 @@ void tst_QSslSocket::setLocalCertificateChain()
QCOMPARE(chain.size(), 2);
QCOMPARE(chain[0].serialNumber(), QByteArray("10:a0:ad:77:58:f6:6e:ae:46:93:a3:43:f9:59:8a:9e"));
QCOMPARE(chain[1].serialNumber(), QByteArray("3b:eb:99:c5:ea:d8:0b:5d:0b:97:5d:4f:06:75:4b:e1"));
socket->deleteLater();
}
void tst_QSslSocket::setPrivateKey()