Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2759

QNetworkAccessManager.setCache should keep cache object alive

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.7.2, 6.8.0
    • 6.7.0, 6.6.3.1
    • PySide
    • All
    • 680b97b17 (dev), 3c34f99ac (6.7)

    Description

      When setting the cache with QNetworkAccessManager.setCache() the passed cache object does get cleaned up if the caller does not keep a reference to the object. It would be expected that passing the cache object to QNetworkAccessManager.setCache() would keep the object alive, as the documentation for QNetworkAccessManager.setCache() states:

      Note: QNetworkAccessManager takes ownership of the cache object.

      The below code shows the principle. A full runnable reproducer is attached with main.py

       

      class SomeClass(QtCore.QObject):
          def __init__(self):
              super().__init__()
              self.access_manager = QtNetwork.QNetworkAccessManager()
              cache = QtNetwork.QNetworkDiskCache()
              self.access_manager.setCache(cache)
              # Uncommenting the below line would prevent the segfault,
              # but this should not be needed.
              # self.cache = cache
      
          def run(self):
              request = QtNetwork.QNetworkRequest(QtCore.QUrl("http://qt-project.org"))
              # The application will segfault in the next call
              self.access_manager.get(request)

      I tested and reproduced the issue with PySide 6.7.0 and 6.6.3.1

       

      Attachments

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

        Activity

          People

            phw Philipp Wolfer
            phw Philipp Wolfer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes