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

Crash When Creating QPixmap From QImage

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:
      None
    • Environment:
      Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)]
    • Platform/s:
      Windows

      Description

      I am converting a project from PyQt5 to Pyside2 and have come accross a section of code that crashes the python interpretter when it runs (but only ~60% of the time???). The code takes a rendered PDF page image from PyMuPDF, converts it to a QImage, then to a QPixmap for display with a QGraphicsPixmapItem. The crash appears to occur on the 'QPixmap.fromImage' method call.

       

      import fitz
      from PySide2 import QtGui, QtWidgets
      
      fname = #Insert any PDF file path here
      pagenum = 3
              
      if __name__ == "__main__":
          import sys
          app = QtWidgets.QApplication(sys.argv)
      
          doc = fitz.open(fname)    
          page = doc[pagenum]
      
          pix = page.get_pixmap()
          doc.close()
          
          qimage = QtGui.QImage(pix.samples, pix.width, pix.height, pix.stride, \ 
                                QtGui.QImage.Format_RGB888)
              
          qpix = QtGui.QPixmap.fromImage(qimage)
          
          qtgi = QtWidgets.QGraphicsPixmapItem(qpix)
      

        Attachments

        1. pyside1563_linux_stack-1.txt
          26 kB
        2. pyside1563.zip
          5 kB
        3. simple loop slabs.pdf
          14 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            kleint Friedemann Kleint
            Reporter:
            bjhowie Ben Howue
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes