Skip to content

Commit

Permalink
JpegImporter,PngImporter: ah, can't const here, sorry.
Browse files Browse the repository at this point in the history
Amazing, the 1970s weren't good. But also, thanks for finally fixing
this in the new versions.
  • Loading branch information
mosra committed Oct 23, 2021
1 parent af11218 commit 7a1b1a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/MagnumPlugins/JpegImporter/JpegImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ Containers::Optional<ImageData2D> JpegImporter::doImage2D(UnsignedInt, UnsignedI

/* Open file */
jpeg_create_decompress(&file);
jpeg_mem_src(&file, reinterpret_cast<const unsigned char*>(_in.begin()), _in.size());
/* Older libjpegs want a mutable pointer, can't const here */
jpeg_mem_src(&file, reinterpret_cast<unsigned char*>(_in.begin()), _in.size());

/* Read file header, start decompression. On macOS (Travis, with Xcode 7.3)
the compilation fails because "no known conversion from 'bool' to
Expand Down
5 changes: 3 additions & 2 deletions src/MagnumPlugins/PngImporter/PngImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ Containers::Optional<ImageData2D> PngImporter::doImage2D(UnsignedInt, UnsignedIn
CORRADE_ASSERT(std::strcmp(PNG_LIBPNG_VER_STRING, png_libpng_ver) == 0,
"Trade::PngImporter::image2D(): libpng version mismatch, got" << png_libpng_ver << "but expected" << PNG_LIBPNG_VER_STRING, Containers::NullOpt);

/* Verify file signature */
if(png_sig_cmp(reinterpret_cast<const unsigned char*>(_in.data()), 0, Math::min(std::size_t(8), _in.size())) != 0) {
/* Verify file signature. Older libpngs want a mutable pointer, can't
const. */
if(png_sig_cmp(reinterpret_cast<unsigned char*>(_in.data()), 0, Math::min(std::size_t(8), _in.size())) != 0) {
Error() << "Trade::PngImporter::image2D(): wrong file signature";
return Containers::NullOpt;
}
Expand Down

0 comments on commit 7a1b1a8

Please sign in to comment.