Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-124326

[OAuth] Fix behaviour when ReplyHandler is not set

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • None

    Description

      The QAbstractOAuth class has function for setting the replyhandler:

      // Setter:
      void QAbstractOAuth::setReplyHandler(QAbstractOAuthReplyHandler *handler);
      
      // Getter:
      QAbstractOAuthReplyHandler *QAbstractOAuth::replyHandler() const
      {
          Q_D(const QAbstractOAuth);
          return d->replyHandler ? d->replyHandler.data() : d->defaultReplyHandler.data();
      }
      

      Now importantly the getter returns a default handler (undocumented QOAuthOobReplyHandler)if the reply handler is not set.
      However, when looking at the code in QOAuth2AuthorizationCodeFlow, it does not use this getter consistently. Instead we can
      see different ways to connect:

      QObjectPrivate::connect(d->replyHandler.data() ... // nullptr if handler is not set
      QAbstractOAuthReplyHandler *handler = replyHandler(); // default handler if handler not set
      QObject::connect(reply, &QNetworkReply::finished, handler,
      

      As a result, if the handler is not set, there are warnings like this:

      qt.core.qobject.connect: QObject::connect(QAbstractOAuthReplyHandler, QOAuth2AuthorizationCodeFlow): invalid nullptr parameter
      

      And things are bound not to work as expected. It should be checked which is the better way and use handler consistently.
      If the handler must always be set, then /that/ must be documented.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              vuokko Juha Vuolle
              vuokko Juha Vuolle
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes