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

QPixmap::loadFromData() doesn't make copy of the data correctly

    XMLWordPrintable

Details

    • 5c2df051cdf8768424fe250bec99b67844df9a36

    Description

      QPixmap::loadFromData(data) overwrites current pixmap data but doesn't make copy of it even pixmap cacheKey is changed. If Pixmap is set to label before loading new data to pixmap it shows incorrectly next data is loaded to pixmap.

          // Doesn't work correctly (Both labels show a green pixmap)
          QPixmap pixmap;
          pixmap.loadFromData(pixmapRed);
          label1.setPixmap(pixmap);
          pixmap.loadFromData(pixmapGreen);
          label2.setPixmap(pixmap);
      

      Workaround is to reset pixmap with empty bytearray before setting new data:

       // Works correctly (Show green and red labels)
          QPixmap pixmap;
          pixmap.loadFromData(pixmapRed);
          label3.setPixmap(pixmap);
          pixmap.loadFromData(QByteArray());  // Reset before setting new data.
          pixmap.loadFromData(pixmapGreen);
          label4.setPixmap(pixmap);
      

      Attachments

        1. QTBUG-43384.zip
          1 kB
        2. reset_always.patch
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ulherman Ulf Hermann
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes