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

"No such signal QObject::finished()" when subclassing QQuickAsyncImageProvider

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.2.2
    • PySide
    • None
    • 58ace971fc (pyside/pyside-setup/dev) edfe2bfcc0 (pyside/pyside-setup/6.2) edfe2bfcc0 (pyside/tqtc-pyside-setup/6.2) 58ace971fc (pyside/tqtc-pyside-setup/dev) edfe2bfcc0 (pyside/pyside-setup/6.2.4) edfe2bfcc0 (pyside/tqtc-pyside-setup/6.2.4)

    Description

      I'm attempting to subclass QQuickAsyncImageProvider and QQuickAsyncImageResponse. I'm already aware of the potential hurdle that, unlike in the C++ example code, with PySide it's not possible to inherit from both QRunnable and QObject. In order to send a signal from my QRunnable I'm instead using an intermediary QObject, as suggested in the comments on PYSIDE-1131. That part works fine.

      However, I'm getting a segmentation fault, sometimes immediately preceded by No such signal QObject::finished() in the console. Here's my code to reproduce the issue:

      from PySide6.QtGui import QGuiApplication, QImage
      from PySide6.QtQml import QQmlApplicationEngine
      from PySide6.QtCore import QObject, QRunnable, QThreadPool, Signal
      from PySide6.QtQuick import (QQuickImageResponse, QQuickAsyncImageProvider,
                                   QQuickTextureFactory)
      
      class Signaller(QObject):
          done = Signal(QImage)
      
      
      class AsyncImageResponseRunnable(QRunnable):
          done = Signal(QImage)
      
          def __init__(self):
              super().__init__()
              self.signaller = Signaller()
              self.done = self.signaller.done
      
          def run(self):
              image = QImage(400, 400, QImage.Format_RGB32)
              image.fill('red')
              self.done.emit(image)
      
      
      class AsyncImageResponse(QQuickImageResponse):
          def __init__(self):
              super().__init__()
      
              runnable = AsyncImageResponseRunnable()
              runnable.done.connect(self.handle_done)
              pool = QThreadPool.globalInstance()
              pool.start(runnable)
      
          def handle_done(self, image):
              self.image = image
              self.finished.emit()
          
          def textureFactory(self):
              return QQuickTextureFactory.textureFactoryForImage(self.image)
      
      
      class AsyncImageProvider(QQuickAsyncImageProvider):
          def requestImageResponse(self, image_id, requested_size):
              return AsyncImageResponse()
      
      
      if __name__ == "__main__":
          app = QGuiApplication()
          engine = QQmlApplicationEngine()
          
          engine.addImageProvider('async_test', AsyncImageProvider())
          
          engine.load('test.qml')
          app.exec()
      
      //test.qml
      
      import QtQuick
      
      Window {
          width: 1200
          height: 800
          visible: true
      
          Image {
              source: 'image://async_test/test'
          }
      }
      

      At first glance, it seems like it would be related to self.finished.emit(). But it's not an AtributeError, and QQuickImageResponse defines the finished signal; plus
      I get the same error message even when I comment out that line. So unless I'm missing something, I guess something else is attempting (and failing) to call it?

       

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            charleswhitt Charles Whittington
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes