diff --git a/doc/changelog.dox b/doc/changelog.dox index f9432aa2b..7143a8c9f 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -659,6 +659,11 @@ See also: forward compatible. - @cpp GL::TextureFormat::R3B3G2 @ce had a misleading typo in the name, use @ref GL::TextureFormat::R3G3B2 instead. +- @ref GL::AbstractTexture destructor is now @cpp protected @ce on builds + with @ref MAGNUM_BUILD_DEPRECATED disabled in order to avoid accidents with + subclass destructors not being called. Right now all subclasses themselves + have trivial destruction, but that may change in the future due to driver + workarounds being added. - @cpp Magnum/MeshTools/GenerateFlatNormals.h @ce is deprecated, use @cpp Magnum/MeshTools/GenerateNormals.h @ce instead - @cpp MeshTools::generateFlatNormals(const std::vector&, const std::vector&) @ce diff --git a/src/Magnum/GL/AbstractTexture.h b/src/Magnum/GL/AbstractTexture.h index 242f1e6de..42aad1de2 100644 --- a/src/Magnum/GL/AbstractTexture.h +++ b/src/Magnum/GL/AbstractTexture.h @@ -317,18 +317,6 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject { /** @brief Move constructor */ AbstractTexture(AbstractTexture&& other) noexcept; - /** - * @brief Destructor - * - * Deletes associated OpenGL texture. - * @see @ref BufferTexture::wrap(), @ref CubeMapTexture::wrap(), - * @ref CubeMapTextureArray::wrap(), - * @ref MultisampleTexture::wrap(), @ref RectangleTexture::wrap(), - * @ref Texture::wrap(), @ref TextureArray::wrap(), - * @ref release(), @fn_gl_keyword{DeleteTextures} - */ - ~AbstractTexture(); - /** @brief Copying is not allowed */ AbstractTexture& operator=(const AbstractTexture&) = delete; @@ -409,6 +397,25 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject { */ void bind(Int textureUnit); + #if !defined(MAGNUM_BUILD_DEPRECATED) || defined(DOXYGEN_GENERATING_OUTPUT) + protected: /* Destructor was public before */ + #endif + /** + * @brief Destructor + * + * Deletes associated OpenGL texture. + * @see @ref BufferTexture::wrap(), @ref CubeMapTexture::wrap(), + * @ref CubeMapTextureArray::wrap(), + * @ref MultisampleTexture::wrap(), @ref RectangleTexture::wrap(), + * @ref Texture::wrap(), @ref TextureArray::wrap(), + * @ref release(), @fn_gl_keyword{DeleteTextures} + */ + /* Not virtual to avoid vtable overhead, however while subclasses are + all the same size (and thus no risk of memory leaks from additional + members) these might perform cleanup steps on destruction (driver + workarouds...), so we have to disallow deletion from base pointer */ + ~AbstractTexture(); + #ifdef DOXYGEN_GENERATING_OUTPUT private: #else