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

QNetworkReplyFileImpl synchronously emits QNetworkReply::finished() from constructor in case of error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15.5, 6.x
    • Fix Version/s: 5.15.11, 6.2.7, 6.5.0 Beta1
    • Component/s: Network
    • Labels:
      None
    • Platform/s:
      All
    • Commits:
      68f641095c (qt/qtbase/dev) 68f641095c (qt/tqtc-qtbase/dev) 678928f4af (qt/tqtc-qtbase/5.15) f2c00dd038 (qt/qtbase/6.4) f2c00dd038 (qt/tqtc-qtbase/6.4) 4a3a7ae6b8 (qt/tqtc-qtbase/6.2) 678928f4af (qt/tqtc-qtbase/5.15-vxworks)

      Description

      https://code.qt.io/cgit/qt/qtbase.git/tree/src/network/access/qnetworkreplyfileimpl.cpp?id=05fc3aef53348fb58be6308076e000825b704e58#n62

       QNetworkReplyFileImpl::QNetworkReplyFileImpl() calls fileOpenFinished(false) #if !defined(Q_OS_WIN) and if (!url.host().isEmpty()).

      QNetworkReplyFileImpl::fileOpenFinished() unconditionally emits finished().

      Other classes derived from QNetworkReply take care to not emit this signal directly from constructor, because the users cannot connect to a signal before the reply object is constructed. Is this a bug or is every QNetworkReply user supposed to check isFinished() after a network reply construction and not rely on finished() being emitted if it returns true? Also if the user code needs to destroy a network reply when finished, is calling deleteLater() on it safe as soon as isFinished() returns true, without waiting for the finished() signal?

      QNetworkReply's documentation could be improved to clarify these usage questions.

        Attachments

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

          Activity

            People

            Assignee:
            manordheim Mårten Nordheim
            Reporter:
            vedg Igor Kushnir
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes