diff options
| author | Juha Vuolle <juha.vuolle@qt.io> | 2024-05-24 15:13:34 +0300 |
|---|---|---|
| committer | Juha Vuolle <juha.vuolle@qt.io> | 2024-05-28 07:29:17 +0300 |
| commit | 15d779b3a682226bb95ec755f18d9701c2813806 (patch) | |
| tree | e7181c635ae4c347c25f79001a56c3932be65f00 /src/oauth/qoauth2authorizationcodeflow.cpp | |
| parent | 25116dddf318bdbb85f890cbfc6df3d93e53d8a6 (diff) | |
[OAuth2] use default handler if no handler is set
QAbstractOAuth baseclass provides replyHandler()
method which returns the reply handler user has set,
or a default handler (oob) if none has been set.
Parts of the implementation however mixed the use of
replyHandler() and the underlying user-settable pointer
directly. This caused "nullptr warnings" with
Q(Private)Object connects.
This commit changes such that only replyHandler() is
used systematically in OAuth2 implementation.
Fixes: QTBUG-124326
Change-Id: If222bde03939ae5a04e4b323774a916a8a57c646
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/oauth/qoauth2authorizationcodeflow.cpp')
| -rw-r--r-- | src/oauth/qoauth2authorizationcodeflow.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/oauth/qoauth2authorizationcodeflow.cpp b/src/oauth/qoauth2authorizationcodeflow.cpp index bf0ec82..3811f5c 100644 --- a/src/oauth/qoauth2authorizationcodeflow.cpp +++ b/src/oauth/qoauth2authorizationcodeflow.cpp @@ -460,15 +460,14 @@ void QOAuth2AuthorizationCodeFlow::refreshAccessToken() connect(reply, &QNetworkReply::finished, handler, [handler, reply]() { handler->networkReplyFinished(reply); }); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater); - QObjectPrivate::connect(d->replyHandler.data(), &QAbstractOAuthReplyHandler::tokensReceived, d, + QObjectPrivate::connect(handler, &QAbstractOAuthReplyHandler::tokensReceived, d, &QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFinished, Qt::UniqueConnection); QObjectPrivate::connect(d->networkAccessManager(), &QNetworkAccessManager::authenticationRequired, d, &QOAuth2AuthorizationCodeFlowPrivate::_q_authenticate, Qt::UniqueConnection); - QObjectPrivate::connect(d->replyHandler.data(), - &QAbstractOAuthReplyHandler::tokenRequestErrorOccurred, + QObjectPrivate::connect(handler, &QAbstractOAuthReplyHandler::tokenRequestErrorOccurred, d, &QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFailed, Qt::UniqueConnection); } @@ -503,7 +502,7 @@ QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QMultiMap<QString, if (d->modifyParametersFunction) d->modifyParametersFunction(Stage::RequestingAuthorization, &p); url.setQuery(d->createQuery(p)); - connect(d->replyHandler.data(), &QAbstractOAuthReplyHandler::callbackReceived, this, + connect(replyHandler(), &QAbstractOAuthReplyHandler::callbackReceived, this, &QOAuth2AuthorizationCodeFlow::authorizationCallbackReceived, Qt::UniqueConnection); setStatus(QAbstractOAuth::Status::NotAuthenticated); qCDebug(d->loggingCategory, "Generated URL: %s", qPrintable(url.toString())); @@ -554,14 +553,14 @@ void QOAuth2AuthorizationCodeFlow::requestAccessToken(const QString &code) QObject::connect(reply, &QNetworkReply::finished, handler, [handler, reply] { handler->networkReplyFinished(reply); }); connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater); - QObjectPrivate::connect(d->replyHandler.data(), &QAbstractOAuthReplyHandler::tokensReceived, d, + QObjectPrivate::connect(handler, &QAbstractOAuthReplyHandler::tokensReceived, d, &QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFinished, Qt::UniqueConnection); QObjectPrivate::connect(d->networkAccessManager(), &QNetworkAccessManager::authenticationRequired, d, &QOAuth2AuthorizationCodeFlowPrivate::_q_authenticate, Qt::UniqueConnection); - QObjectPrivate::connect(d->replyHandler.data(), + QObjectPrivate::connect(handler, &QAbstractOAuthReplyHandler::tokenRequestErrorOccurred, d, &QOAuth2AuthorizationCodeFlowPrivate::_q_accessTokenRequestFailed, Qt::UniqueConnection); |
