tst_grpc_client: port from QSharedPointer to std::unique_ptr

The sharing capabilities of shared_ptr aren't used here, so use a
const unique_ptr, aka a scoped pointer.

Pick-to: 6.5
Task-number: QTBUG-108833
Change-Id: I55977d18744627f56603d64816a6f13f254ab06f
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2022-12-22 22:22:41 +01:00
parent c4754ea69e
commit bdac28b542
1 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,8 @@
#include <QtCore/QThread>
#include <QtCore/QTimer>
#include <memory>
#if QT_CONFIG(native_grpc)
# include <grpcpp/security/credentials.h>
#endif
@ -600,7 +602,7 @@ void QtGrpcClientTest::CallStringThreadTest()
QVERIFY(clientErrorSpy.isValid());
bool ok = false;
QSharedPointer<QThread> thread(QThread::create([&] {
const std::unique_ptr<QThread> thread(QThread::create([&] {
ok = _client->testMethod(request, result.get()) == QGrpcStatus::Ok;
}));
@ -623,7 +625,7 @@ void QtGrpcClientTest::StringAsyncThreadTest()
QSignalSpy clientErrorSpy(_client.get(), &TestService::Client::errorOccurred);
QVERIFY(clientErrorSpy.isValid());
QSharedPointer<QThread> thread(QThread::create([&] {
const std::unique_ptr<QThread> thread(QThread::create([&] {
QEventLoop waiter;
std::shared_ptr<QGrpcCallReply> reply = _client->testMethod(request);
QObject::connect(reply.get(), &QGrpcCallReply::finished, &waiter,
@ -654,7 +656,7 @@ void QtGrpcClientTest::StreamStringThreadTest()
QVERIFY(clientErrorSpy.isValid());
int i = 0;
QSharedPointer<QThread> thread(QThread::create([&] {
const std::unique_ptr<QThread> thread(QThread::create([&] {
QEventLoop waiter;
auto stream = _client->streamTestMethodServerStream(request);
QObject::connect(stream.get(), &QGrpcStream::messageReceived, &waiter,