mirror of https://github.com/qt/qtgrpc.git
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:
parent
c4754ea69e
commit
bdac28b542
|
|
@ -20,6 +20,8 @@
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#if QT_CONFIG(native_grpc)
|
#if QT_CONFIG(native_grpc)
|
||||||
# include <grpcpp/security/credentials.h>
|
# include <grpcpp/security/credentials.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -600,7 +602,7 @@ void QtGrpcClientTest::CallStringThreadTest()
|
||||||
QVERIFY(clientErrorSpy.isValid());
|
QVERIFY(clientErrorSpy.isValid());
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
QSharedPointer<QThread> thread(QThread::create([&] {
|
const std::unique_ptr<QThread> thread(QThread::create([&] {
|
||||||
ok = _client->testMethod(request, result.get()) == QGrpcStatus::Ok;
|
ok = _client->testMethod(request, result.get()) == QGrpcStatus::Ok;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -623,7 +625,7 @@ void QtGrpcClientTest::StringAsyncThreadTest()
|
||||||
QSignalSpy clientErrorSpy(_client.get(), &TestService::Client::errorOccurred);
|
QSignalSpy clientErrorSpy(_client.get(), &TestService::Client::errorOccurred);
|
||||||
QVERIFY(clientErrorSpy.isValid());
|
QVERIFY(clientErrorSpy.isValid());
|
||||||
|
|
||||||
QSharedPointer<QThread> thread(QThread::create([&] {
|
const std::unique_ptr<QThread> thread(QThread::create([&] {
|
||||||
QEventLoop waiter;
|
QEventLoop waiter;
|
||||||
std::shared_ptr<QGrpcCallReply> reply = _client->testMethod(request);
|
std::shared_ptr<QGrpcCallReply> reply = _client->testMethod(request);
|
||||||
QObject::connect(reply.get(), &QGrpcCallReply::finished, &waiter,
|
QObject::connect(reply.get(), &QGrpcCallReply::finished, &waiter,
|
||||||
|
|
@ -654,7 +656,7 @@ void QtGrpcClientTest::StreamStringThreadTest()
|
||||||
QVERIFY(clientErrorSpy.isValid());
|
QVERIFY(clientErrorSpy.isValid());
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QSharedPointer<QThread> thread(QThread::create([&] {
|
const std::unique_ptr<QThread> thread(QThread::create([&] {
|
||||||
QEventLoop waiter;
|
QEventLoop waiter;
|
||||||
auto stream = _client->streamTestMethodServerStream(request);
|
auto stream = _client->streamTestMethodServerStream(request);
|
||||||
QObject::connect(stream.get(), &QGrpcStream::messageReceived, &waiter,
|
QObject::connect(stream.get(), &QGrpcStream::messageReceived, &waiter,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue