mirror of https://github.com/qt/qtgrpc.git
Remove unnecessary QObject:: namespace to improve readability
Removed redundant 'QObject::' namespace to streamline code and enhance readability, especially in lambda handlers. Due to our formatting, all lambda handlers will be unnecessarily aligned to the very right side. Given that connections and lambda handlers are very common in this codebase this improves the readability of those lambda handlers. Change-Id: I178a838c7702382b4b3845c729d7c11eeeb1c8d1 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> (cherry picked from commiteb703a45a1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit2720a3e74d) Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit7a3ebbc1f9)
This commit is contained in:
parent
e56545b318
commit
84b552086d
|
|
@ -354,8 +354,7 @@ private:
|
|||
template <typename T>
|
||||
void connectErrorHandler(T *socket, Http2Handler *handler)
|
||||
{
|
||||
QObject::connect(socket, &T::errorOccurred, handler,
|
||||
[this, handler](auto error) {
|
||||
connect(socket, &T::errorOccurred, handler, [this, handler](auto error) {
|
||||
if (m_isInsideSocketErrorOccurred) {
|
||||
qCCritical(lcChannel,
|
||||
"[%p] Socket errorOccurred signal triggered while "
|
||||
|
|
@ -364,9 +363,7 @@ private:
|
|||
return;
|
||||
}
|
||||
m_isInsideSocketErrorOccurred = true;
|
||||
auto reset = qScopeGuard([this]() {
|
||||
m_isInsideSocketErrorOccurred = false;
|
||||
});
|
||||
auto reset = qScopeGuard([this]() { m_isInsideSocketErrorOccurred = false; });
|
||||
emit handler->finish({ StatusCode::Unavailable,
|
||||
tr("Network error occurred: %1").arg(error) });
|
||||
});
|
||||
|
|
@ -445,18 +442,15 @@ Http2Handler::Http2Handler(QGrpcHttp2ChannelPrivate *parent, QGrpcOperationConte
|
|||
// If the context (lifetime bound to the user) is destroyed, this handler
|
||||
// can no longer perform any meaningful work. We allow it to be deleted;
|
||||
// QHttp2Stream will handle any outstanding cancellations appropriately.
|
||||
QObject::connect(context, &QGrpcOperationContext::destroyed, this,
|
||||
&Http2Handler::deleteLater);
|
||||
QObject::connect(context, &QGrpcOperationContext::cancelRequested, this,
|
||||
&Http2Handler::cancel);
|
||||
QObject::connect(context, &QGrpcOperationContext::writesDoneRequested, this,
|
||||
&Http2Handler::writesDone);
|
||||
connect(context, &QGrpcOperationContext::destroyed, this, &Http2Handler::deleteLater);
|
||||
connect(context, &QGrpcOperationContext::cancelRequested, this, &Http2Handler::cancel);
|
||||
connect(context, &QGrpcOperationContext::writesDoneRequested, this, &Http2Handler::writesDone);
|
||||
if (!m_endStreamAtFirstData) {
|
||||
QObject::connect(context, &QGrpcOperationContext::writeMessageRequested, this,
|
||||
connect(context, &QGrpcOperationContext::writeMessageRequested, this,
|
||||
&Http2Handler::writeMessage);
|
||||
}
|
||||
|
||||
QObject::connect(context, &QGrpcOperationContext::finished, &m_deadlineTimer, &QTimer::stop);
|
||||
connect(context, &QGrpcOperationContext::finished, &m_deadlineTimer, &QTimer::stop);
|
||||
m_deadlineTimer.setSingleShot(true);
|
||||
|
||||
writeMessage(context->argument());
|
||||
|
|
@ -481,14 +475,14 @@ void Http2Handler::attachStream(QHttp2Stream *stream_)
|
|||
|
||||
m_stream = stream_;
|
||||
|
||||
QObject::connect(m_stream.get(), &QHttp2Stream::headersReceived, this,
|
||||
connect(m_stream.get(), &QHttp2Stream::headersReceived, this,
|
||||
[this](const HPack::HttpHeader &headers, bool endStream) mutable {
|
||||
if (m_state >= State::Cancelled) {
|
||||
// In case we are Cancelled or Finished, a
|
||||
// finished has been emitted already and the
|
||||
// Handler should get deleted here.
|
||||
qCDebug(lcStream, "[%p] Ignoring headers - already closed (state=%s)",
|
||||
this, QDebug::toBytes(m_state).constData());
|
||||
qCDebug(lcStream, "[%p] Ignoring headers - already closed (state=%s)", this,
|
||||
QDebug::toBytes(m_state).constData());
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
|
|
@ -513,14 +507,14 @@ void Http2Handler::attachStream(QHttp2Stream *stream_)
|
|||
handleHeaders(headers, phase);
|
||||
});
|
||||
|
||||
QObject::connect(
|
||||
connect(
|
||||
m_stream.get(), &QHttp2Stream::errorOccurred, this,
|
||||
[this](quint32 http2ErrorCode, const QString &errorString) {
|
||||
finish({ http2ErrorToStatusCode(http2ErrorCode), errorString });
|
||||
},
|
||||
Qt::SingleShotConnection);
|
||||
|
||||
QObject::connect(m_stream.get(), &QHttp2Stream::dataReceived, m_context.get(),
|
||||
connect(m_stream.get(), &QHttp2Stream::dataReceived, m_context.get(),
|
||||
[this](const QByteArray &data, bool endStream) {
|
||||
if (m_state == State::Cancelled)
|
||||
return;
|
||||
|
|
@ -536,10 +530,8 @@ void Http2Handler::attachStream(QHttp2Stream *stream_)
|
|||
"expectedSize=%" PRIdQSIZETYPE ", containerSize=%" PRIdQSIZETYPE ")",
|
||||
this, data.size(), m_expectedData.expectedSize,
|
||||
m_expectedData.container.size());
|
||||
const auto len = m_expectedData.expectedSize
|
||||
- GrpcMessageSizeHeaderSize;
|
||||
const auto msg = m_expectedData.container
|
||||
.mid(GrpcMessageSizeHeaderSize, len);
|
||||
const auto len = m_expectedData.expectedSize - GrpcMessageSizeHeaderSize;
|
||||
const auto msg = m_expectedData.container.mid(GrpcMessageSizeHeaderSize, len);
|
||||
emit m_context->messageReceived(msg);
|
||||
|
||||
m_expectedData.container.remove(0, m_expectedData.expectedSize);
|
||||
|
|
@ -552,8 +544,7 @@ void Http2Handler::attachStream(QHttp2Stream *stream_)
|
|||
finish({});
|
||||
});
|
||||
|
||||
QObject::connect(m_stream.get(), &QHttp2Stream::uploadFinished, this,
|
||||
&Http2Handler::processQueue);
|
||||
connect(m_stream.get(), &QHttp2Stream::uploadFinished, this, &Http2Handler::processQueue);
|
||||
}
|
||||
|
||||
// Builds HTTP/2 headers for the initial gRPC request.
|
||||
|
|
@ -930,9 +921,9 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
|||
auto *localSocket = initSocket<QLocalSocket>();
|
||||
m_isLocalSocket = true;
|
||||
|
||||
QObject::connect(localSocket, &QLocalSocket::connected, this,
|
||||
connect(localSocket, &QLocalSocket::connected, this,
|
||||
&QGrpcHttp2ChannelPrivate::createHttp2Connection);
|
||||
QObject::connect(localSocket, &QLocalSocket::errorOccurred, this,
|
||||
connect(localSocket, &QLocalSocket::errorOccurred, this,
|
||||
&QGrpcHttp2ChannelPrivate::handleLocalSocketError);
|
||||
|
||||
m_reconnectFunction = [localSocket, this] {
|
||||
|
|
@ -964,9 +955,9 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
|||
sslSocket->setSslConfiguration(defautlSslConfig);
|
||||
}
|
||||
|
||||
QObject::connect(sslSocket, &QSslSocket::encrypted, this,
|
||||
connect(sslSocket, &QSslSocket::encrypted, this,
|
||||
&QGrpcHttp2ChannelPrivate::createHttp2Connection);
|
||||
QObject::connect(sslSocket, &QAbstractSocket::errorOccurred, this,
|
||||
connect(sslSocket, &QAbstractSocket::errorOccurred, this,
|
||||
&QGrpcHttp2ChannelPrivate::handleAbstractSocketError);
|
||||
|
||||
m_reconnectFunction = [sslSocket, this] {
|
||||
|
|
@ -985,9 +976,9 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
|||
nonDefaultPort = hostUri.port() != 80;
|
||||
}
|
||||
|
||||
QObject::connect(httpSocket, &QAbstractSocket::connected, this,
|
||||
connect(httpSocket, &QAbstractSocket::connected, this,
|
||||
&QGrpcHttp2ChannelPrivate::createHttp2Connection);
|
||||
QObject::connect(httpSocket, &QAbstractSocket::errorOccurred, this,
|
||||
connect(httpSocket, &QAbstractSocket::errorOccurred, this,
|
||||
&QGrpcHttp2ChannelPrivate::handleAbstractSocketError);
|
||||
|
||||
m_reconnectFunction = [httpSocket, this] {
|
||||
|
|
@ -1078,14 +1069,14 @@ void QGrpcHttp2ChannelPrivate::createHttp2Connection()
|
|||
m_connection = QHttp2Connection::createDirectConnection(m_socket.get(), {});
|
||||
|
||||
Q_ASSERT_X(m_connection, "QGrpcHttp2ChannelPrivate", "Unable to create the HTTP/2 connection");
|
||||
QObject::connect(m_socket.get(), &QAbstractSocket::readyRead, m_connection,
|
||||
connect(m_socket.get(), &QAbstractSocket::readyRead, m_connection,
|
||||
&QHttp2Connection::handleReadyRead);
|
||||
|
||||
m_state = ConnectionState::Connected;
|
||||
qCDebug(lcChannel, "[%p] Created new HTTP/2 connection to %s", this,
|
||||
qPrintable(hostUri.toString()));
|
||||
|
||||
QObject::connect(m_connection, &QHttp2Connection::settingsFrameReceived, this, [this] {
|
||||
connect(m_connection, &QHttp2Connection::settingsFrameReceived, this, [this] {
|
||||
if (m_state == ConnectionState::SettingsReceived) {
|
||||
qCWarning(lcChannel,
|
||||
"[%p] Unexpected SETTINGS frame received multiple times in this session.",
|
||||
|
|
|
|||
Loading…
Reference in New Issue