diff --git a/doc/changelog.dox b/doc/changelog.dox index f6e0c5743..db098fb9d 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1751,6 +1751,9 @@ See also: - Templated @cpp Image*::data() @ce APIs returning a pointer which allowed for dangerous data access without any bounds, type or layout checks, use @ref Image::pixels() instead + - Passing empty data with a non-zero size to @ref ImageView constructors, + which caused a runtime deprecation warning, is not allowed anymore. Use + a constructor without the data parameter instead. - @cpp GL::TextureFormat::R3B3G2 @ce containing a typo, use @ref GL::TextureFormat::R3G3B2 instead - @cpp Platform::GlfwApplication::Key::Smicolon @ce containing a typo, diff --git a/src/Magnum/ImageView.cpp b/src/Magnum/ImageView.cpp index a6ee50a58..af036e303 100644 --- a/src/Magnum/ImageView.cpp +++ b/src/Magnum/ImageView.cpp @@ -36,15 +36,7 @@ template ImageView::ImageView(co template ImageView::ImageView(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: ImageView{storage, pixelFormatWrap(format), formatExtra, pixelSize, size, data, flags} {} template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{pixelSize}, _flags{flags}, _size{size}, _data{reinterpret_cast(data.data()), data.size()} { - #ifdef MAGNUM_BUILD_DEPRECATED - #ifndef CORRADE_NO_ASSERT - if(size.product() && !_data && !_data.size()) - Warning{} << "ImageView: passing empty data to a non-empty view is deprecated, use a constructor without the data parameter instead"; - #endif - CORRADE_ASSERT(!_data || Implementation::imageDataSize(*this) <= _data.size(), "ImageView: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); - #else CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "ImageView: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); - #endif #ifndef CORRADE_NO_ASSERT Implementation::checkImageFlagsForSize("ImageView:", flags, size); #endif diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index 3470c1e4a..d6b9dc731 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -657,16 +657,12 @@ void ImageViewTest::constructCompressedFromMutable() { } void ImageViewTest::constructNullptr() { - #ifdef MAGNUM_BUILD_DEPRECATED - CORRADE_SKIP("This is still allowed on a deprecated build, can't test."); - #elif defined(CORRADE_NO_ASSERT) - CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); - #else + CORRADE_SKIP_IF_NO_ASSERT(); + Containers::String out; Error redirectError{&out}; ImageView2D{PixelFormat::RGB8Unorm, {1, 3}, nullptr}; CORRADE_COMPARE(out, "ImageView: data too small, got 0 but expected at least 12 bytes\n"); - #endif } void ImageViewTest::constructInvalidSize() {