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

createTextureFromImage() creates one extra copy of image

    XMLWordPrintable

Details

    Description

      In 2D renderer mode, the function createTextureFromImage(const QImage &image) creates one extra instance of QImage and keeps it unreleased.
      It creates the issue for us as in our application we use the ability of QImage to create multiple instances of QImage from the same buffer: QImage(uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = Q_NULLPTR, void *cleanupInfo = Q_NULLPTR) and possibility to count the number of instances by using the cleanup function.

      Steps to reproduce:
      1. Run the attached code example.
      2 Observe the debug output of the application:
      the current output for 2D renderer:

      updatePaintNode(), frame# 0
      ++refCount = 1
      updatePaintNode(), frame# 1
      ++refCount = 2
      --refCount = 1
      updatePaintNode(), frame# 2
      ++refCount = 2
      --refCount = 1
      updatePaintNode(), frame# 3
      ++refCount = 2
      --refCount = 1
      
      Expected output, and the output with OpenGl renderer:
      updatePaintNode(), frame# 0
      ++refCount = 1
      --refCount = 0
      updatePaintNode(), frame# 1
      ++refCount = 1
      --refCount = 0
      updatePaintNode(), frame# 2
      ++refCount = 1
      --refCount = 0
      updatePaintNode(), frame# 3
      ++refCount = 1
      --refCount = 0
      

      As you can see one in 2D renderer mode one extra copy of the the image is created and not released for a long time. I noticed that this image is sometimes is been released spontaneously after several seconds if some CPU idling is added. Reproduced on macOS high Sierra and Windows 10

      Attachments

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

        Activity

          People

            janichol Andy Nichols
            oleg_petrov Oleg Petrov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes