• Tomaž Vajngerl's avatar
    tdf#100184 fix the lifecycle of a texture in an atlas · 8dcf60ec
    Tomaž Vajngerl yazdı
    Previously, when a texture atlas was destroyed we teared down
    the  ImplOpenGLTexture even if there were OpenGLTexture instances
    around. This caused that we could try to access an already
    deallocated ImplOpenGLTexture which causes a seg. fault.
    
    Now we change this so that a FixedTexture is no different than a
    OpenGLTexture - we just release the reference, so any existing
    OpenGLTextures for our texture would still be valid.
    
    An additional problem is that FixedTexture registers a callback
    for slot deallocation so we know when a OpenGLTextures that holds
    a specific "slot" on the texture is deallocated. However if
    FixedTexture is not existent anymore, the callback still gets
    triggered and is trying to access invalid memory. To solve this
    we need to unregister callbacks before FixedTexture is destroyed.
    
    Additionally improve validity of a OpenGLTexture is valid. If
    ImplOpenGLTexture is not allocated (nullptr) is one case, but in
    addition to that if ImplOpenGLTexture has an id == 0 it also means
    that it is not valid (anymore).
    
    Change-Id: I87346198e8928e112619da62687d5856cb8aafb8
    8dcf60ec
texture.cxx 18 KB