Browse Source

Disallow calling data() on rvalue Image and Trade::ImageData.

That would cause accessing freed data. Use release() instead (and then
you are on your own). The AbstractShaderProgram GL test now fails to
compile.
pull/157/head
Vladimír Vondruš 10 years ago
parent
commit
258ab1a92c
  1. 18
      src/Magnum/Image.h
  2. 18
      src/Magnum/Trade/ImageData.h

18
src/Magnum/Image.h

@ -144,10 +144,24 @@ template<UnsignedInt dimensions> class Image {
*
* @see @ref release()
*/
Containers::ArrayView<char> data() { return _data; }
Containers::ArrayView<char> data()
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data; }
#ifndef CORRADE_GCC47_COMPATIBILITY
Containers::ArrayView<char> data() && = delete; /**< @overload */
#endif
/** @overload */
Containers::ArrayView<const char> data() const { return _data; }
Containers::ArrayView<const char> data() const
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data; }
#ifndef CORRADE_GCC47_COMPATIBILITY
Containers::ArrayView<const char> data() const && = delete; /**< @overload */
#endif
/** @overload */
template<class T = char> T* data() {

18
src/Magnum/Trade/ImageData.h

@ -221,10 +221,24 @@ template<UnsignedInt dimensions> class ImageData {
*
* @see @ref release()
*/
Containers::ArrayView<char> data() { return _data; }
Containers::ArrayView<char> data()
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data; }
#ifndef CORRADE_GCC47_COMPATIBILITY
Containers::ArrayView<char> data() && = delete; /**< @overload */
#endif
/** @overload */
Containers::ArrayView<const char> data() const { return _data; }
Containers::ArrayView<const char> data() const
#ifndef CORRADE_GCC47_COMPATIBILITY
&
#endif
{ return _data; }
#ifndef CORRADE_GCC47_COMPATIBILITY
Containers::ArrayView<const char> data() const && = delete; /**< @overload */
#endif
/** @overload */
template<class T> T* data() {

Loading…
Cancel
Save