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

QNetworkAccessManager/QNetworkConfigurationManager failure if QApplication is gone

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.11.0
    • Network
    • None
    • Windows

    Description

      I already have reported this issue in QTBUG-36897, finally I managed to reproduce it in code isolated from framework I use. Here is minimal example that will cause the problem (Using Windows 10, Qt 5.11.0, Visual Studio 2017, x64): 

      #include <QNetworkAccessManager>
      #include <QApplication>
       
      void main(int c, char** p)
      {
        {
          QNetworkAccessManager m;    // L1
        }
        {
          int argc = 0;
          QApplication app(argc, {}); // L2
        }
        {
          QNetworkAccessManager m;    // L3
        }
      }

      If you comment out any of L1,L2,L3 lines it will work. But having all those 3 lines will cause following to be printed:

      QObject::connect: Cannot connect (null)::configurationAdded(QNetworkConfiguration) to QNetworkConfigurationManager::configurationAdded(QNetworkConfiguration)
      QObject::connect: Cannot connect (null)::configurationRemoved(QNetworkConfiguration) to QNetworkConfigurationManager::configurationRemoved(QNetworkConfiguration)
      QObject::connect: Cannot connect (null)::configurationChanged(QNetworkConfiguration) to QNetworkConfigurationManager::configurationChanged(QNetworkConfiguration)
      QObject::connect: Cannot connect (null)::onlineStateChanged(bool) to QNetworkConfigurationManager::onlineStateChanged(bool)
      QObject::connect: Cannot connect (null)::configurationUpdateComplete() to QNetworkConfigurationManager::updateCompleted()

      We do have bunch of unit tests using QNetworkAccessManager, some of them creating QApplication, some of them not. After few tests the testing app crash. Workaround is to create QNetworkAccessManager first before any QApplication and share it in all unit tests, QNetworkAccessManager created before QApplication works fine even if QApplication get destroyed.

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            9a4gl Tihomir Heidelberg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes