diff --git a/src/Plugins/MagnumFont/MagnumFont.cpp b/src/Plugins/MagnumFont/MagnumFont.cpp index c14fef1f0..8fdbeedf9 100644 --- a/src/Plugins/MagnumFont/MagnumFont.cpp +++ b/src/Plugins/MagnumFont/MagnumFont.cpp @@ -102,14 +102,13 @@ void MagnumFont::doOpenData(const std::vector image = importer.image2D(0); if(!image) { Error() << "Text::MagnumFont::openData(): cannot load image file"; return; } openInternal(std::move(conf), std::move(*image)); - delete image; } void MagnumFont::doOpenFile(const std::string& filename, Float) { @@ -134,14 +133,13 @@ void MagnumFont::doOpenFile(const std::string& filename, Float) { Error() << "Text::MagnumFont::openFile(): cannot open image file" << imageFilename; return; } - Trade::ImageData2D* image = importer.image2D(0); + std::optional image = importer.image2D(0); if(!image) { Error() << "Text::MagnumFont::openFile(): cannot load image file"; return; } openInternal(std::move(conf), std::move(*image)); - delete image; } void MagnumFont::openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image) { diff --git a/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp b/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp index 2ef161a5a..25e37df0c 100644 --- a/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp +++ b/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp @@ -88,7 +88,8 @@ void MagnumFontConverterTest::exportFont() { /* Verify font image, no need to test image contents, as the image is garbage anyway */ Trade::TgaImporter importer; CORRADE_VERIFY(importer.openFile(Utility::Directory::join(MAGNUMFONTCONVERTER_TEST_WRITE_DIR, "font.tga"))); - Trade::ImageData2D* image = importer.image2D(0); + std::optional image = importer.image2D(0); + CORRADE_VERIFY(image); CORRADE_COMPARE(image->size(), Vector2i(256)); CORRADE_COMPARE(image->format(), ImageFormat::Red); CORRADE_COMPARE(image->type(), ImageType::UnsignedByte);