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

QOpenGLFramebufferObject::takeTexture() is leaking

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.4, 6.2.0 FF, 6.3.0
    • GUI: OpenGL
    • None
    • All

    Description

      In qopenglframebufferobject.cpp, line 600 a QOpenGLSharedResourceGuard is allocated. In line 1313 ( takeTexture() ) the corresponding pointer is simply set to NULL without deleting the guard - finally ending up as memory leak.

      IMHO a better solution would be to call invalidateResource(). Then the guard will properly be deleted without releasing the taken texture.

      In my code QOpenGLFramebufferObject::takeTexture() is called for every update of a texture and the leaks are summing up siginficantly.

      My ( nicht jugendfreier ) workaround looks like this:

      #include <private/qopenglframebufferobject_p.h>
      
      GLuint qskTakeTexture( QOpenGLFramebufferObject& fbo )
      {   
          class MyFBO
          {   
              public:
                  virtual ~MyFBO() = default;
                  QScopedPointer<QOpenGLFramebufferObjectPrivate> d_ptr;
          };  
      
          static_assert( sizeof( MyFBO ) == sizeof( QOpenGLFramebufferObject ),
              "Bad cast: QOpenGLFramebufferObject does not match" );
      
          auto& attachment = reinterpret_cast< MyFBO* >( &fbo )->d_ptr->colorAttachments[0];
          auto guard = attachment.guard;
      
          const auto textureId = fbo.takeTexture();
      
          if ( guard )
          {   
              class MyGuard : public QOpenGLSharedResourceGuard
              {   
                  public:
                      void invalidateTexture() { invalidateResource(); }
              };  
      
              reinterpret_cast< MyGuard* >( guard )->invalidateTexture();
          }   
      
          attachment.guard = guard;
      
          return textureId;
      }
      

      Attachments

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

        Activity

          People

            lagocs Laszlo Agocs
            uwe Uwe Rathmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes