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

QImage::paintEngine() crashes when called on copy

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.12.5
    • GUI: Painting
    • None
    • Linux/X11
    • 03717be7885d84783bc8ea32a65e42e4970f59d6 (qt/qtbase/5.15)

    Description

      Hello,

      when creating a shallow copy of a QImage and calling paintEngine the internal QPaintEngine is not created properly.

      #include <QImage>
      
      int main()
      {
          const QImage srcImage{"path/to/image"};
          assert(!srcImage.isNull());
          auto destImage = srcImage;
          assert(destImage.paintEngine() != nullptr);
          return EXIT_SUCCESS;
      }
      

      This application crashes at the assert because the paintengine is not created properly.
      Calling QImage::copy to create a deep copy is a valid work around. Calling destImage.paintEngine one time before using leads also to creation of the PaintEngine in the right object.

      Maybe the QImage class should be searched for missing detach() calls in all its non-const member functions.

      Attachments

        For Gerrit Dashboard: QTBUG-79383
        # Subject Branch Project Status CR V

        Activity

          People

            vgt Eirik Aavitsland
            Psy-Kai Kai Dohmen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes