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

QSGOpaqueTextureMaterial::compare sometimes segfaults when using QQuickImageProvider which returns non-transparent pixmap

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.2.0
    • Quick: SceneGraph
    • None
    • Qt 5.2 from git stable branch
      Linux (Ubuntu 12.10)
    • 486d367e8086e63f51707e78c07ef77fa6240f0a

    Description

      Segfault occurs in the code below.
      I am using Qt 5.2 stable from git.

      int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const
      {
          Q_ASSERT(o && type() == o->type());
          const QSGOpaqueTextureMaterial *other = static_cast<const QSGOpaqueTextureMaterial *>(o);
          if (int diff = m_texture->textureId() - other->texture()->textureId())
              return diff;
          return int(m_filtering) - int(other->m_filtering);
      }
      

      on

      if (int diff = m_texture->textureId() - other->texture()->textureId())
      

      because other->texture() returns 0

      I am not sure why this happens.
      In my case it appears to happen when my QQuickImageProvider::requestPixmap returns a pixmap without alpha channel. For example:

      QPixmap RoundedImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
      {
          int width = 800;
          int height = 800;
          if (size)
              *size = QSize(width, height);
          QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width,
                         requestedSize.height() > 0 ? requestedSize.height() : height);
          pixmap.fill(Qt::red);
      
          // Draw on pixmap here
      
          return pixmap;
      }
      

      might cause the segfault but if I replace Qt::red with Qt::transparent there is no segfault. There is also no segfault if I first fill with Qt::transparent and then with Qt::red (probably because the pixmap gets an alpha channel then)

      Might be worth to check out what might actually go wrong? Perhaps other problems are triggered by the offending code.

      Attachments

        Issue Links

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

          Activity

            People

              sletta Gunnar Sletta
              profox Wesley Stessens
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes