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

QImage::paintEngine() crashes when called on copy

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.12.5
    • Fix Version/s: None
    • Component/s: GUI: Painting
    • Labels:
      None
    • Platform/s:
      Linux/X11
    • Commits:
      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

            • Assignee:
              vgt Eirik Aavitsland
              Reporter:
              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