From 715630b375b413eb05232803b5be68489bee5e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Nov 2013 21:47:53 +0100 Subject: [PATCH] GCC 4.5 compatibility: nullptr-related issues. --- .../Test/MagnumFontConverterTest.cpp | 2 +- .../TgaImageConverter/TgaImageConverter.cpp | 8 ++++++++ src/Plugins/WavAudioImporter/WavImporter.cpp | 8 +++++++- src/Text/AbstractFont.cpp | 8 ++++---- src/Text/AbstractFontConverter.cpp | 20 +++++++++---------- src/Text/Test/AbstractFontConverterTest.cpp | 2 +- src/Text/Test/AbstractFontTest.cpp | 2 +- 7 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp b/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp index e0676f0e3..d04b0358b 100644 --- a/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp +++ b/src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp @@ -70,7 +70,7 @@ void MagnumFontConverterTest::exportFont() { return {16.0f, 39.7333f}; } Features doFeatures() const { return {}; } - std::unique_ptr doLayout(const GlyphCache&, Float, const std::string&) { return nullptr; } + std::unique_ptr doLayout(const GlyphCache&, Float, const std::string&) { return {}; } UnsignedInt doGlyphId(const char32_t character) { switch(character) { diff --git a/src/Plugins/TgaImageConverter/TgaImageConverter.cpp b/src/Plugins/TgaImageConverter/TgaImageConverter.cpp index fdb9c8c11..242377e58 100644 --- a/src/Plugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/Plugins/TgaImageConverter/TgaImageConverter.cpp @@ -60,12 +60,20 @@ Containers::Array TgaImageConverter::doExportToData(const ImageRe #endif { Error() << "Trade::TgaImageConverter::convertToData(): unsupported image format" << image.format(); + #ifndef CORRADE_GCC45_COMPATIBILITY return nullptr; + #else + return {}; + #endif } if(image.type() != ColorType::UnsignedByte) { Error() << "Trade::TgaImageConverter::convertToData(): unsupported image type" << image.type(); + #ifndef CORRADE_GCC45_COMPATIBILITY return nullptr; + #else + return {}; + #endif } /* Initialize data buffer */ diff --git a/src/Plugins/WavAudioImporter/WavImporter.cpp b/src/Plugins/WavAudioImporter/WavImporter.cpp index db93e0885..181c77a29 100644 --- a/src/Plugins/WavAudioImporter/WavImporter.cpp +++ b/src/Plugins/WavAudioImporter/WavImporter.cpp @@ -115,7 +115,13 @@ void WavImporter::doOpenData(Containers::ArrayReference dat return; } -void WavImporter::doClose() { _data = nullptr; } +void WavImporter::doClose() { + #ifndef CORRADE_GCC45_COMPATIBILITY + _data = nullptr; + #else + _data = {}; + #endif +} Buffer::Format WavImporter::doFormat() const { return _format; } diff --git a/src/Text/AbstractFont.cpp b/src/Text/AbstractFont.cpp index 75fd06609..51efbb676 100644 --- a/src/Text/AbstractFont.cpp +++ b/src/Text/AbstractFont.cpp @@ -145,19 +145,19 @@ void AbstractFont::doFillGlyphCache(GlyphCache&, const std::vector&) std::unique_ptr AbstractFont::createGlyphCache() { CORRADE_ASSERT(isOpened(), - "Text::AbstractFont::createGlyphCache(): no font opened", nullptr); + "Text::AbstractFont::createGlyphCache(): no font opened", {}); CORRADE_ASSERT(features() & Feature::PreparedGlyphCache, - "Text::AbstractFont::createGlyphCache(): feature not supported", nullptr); + "Text::AbstractFont::createGlyphCache(): feature not supported", {}); return doCreateGlyphCache(); } std::unique_ptr AbstractFont::doCreateGlyphCache() { - CORRADE_ASSERT(false, "Text::AbstractFont::createGlyphCache(): feature advertised but not implemented", nullptr); + CORRADE_ASSERT(false, "Text::AbstractFont::createGlyphCache(): feature advertised but not implemented", {}); } std::unique_ptr AbstractFont::layout(const GlyphCache& cache, const Float size, const std::string& text) { - CORRADE_ASSERT(isOpened(), "Text::AbstractFont::layout(): no font opened", nullptr); + CORRADE_ASSERT(isOpened(), "Text::AbstractFont::layout(): no font opened", {}); return doLayout(cache, size, text); } diff --git a/src/Text/AbstractFontConverter.cpp b/src/Text/AbstractFontConverter.cpp index 762c20127..c11f613cd 100644 --- a/src/Text/AbstractFontConverter.cpp +++ b/src/Text/AbstractFontConverter.cpp @@ -199,52 +199,52 @@ bool AbstractFontConverter::doExportGlyphCacheToFile(GlyphCache& cache, const st std::unique_ptr AbstractFontConverter::importGlyphCacheFromData(const std::vector>>& data) const { CORRADE_ASSERT(features() >= (Feature::ImportGlyphCache|Feature::ConvertData), - "Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromData(): feature not supported", {}); CORRADE_ASSERT(!data.empty(), - "Text::AbstractFontConverter::importGlyphCacheFromData(): no data passed", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromData(): no data passed", {}); return doImportGlyphCacheFromData(data); } std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromData(const std::vector>>& data) const { CORRADE_ASSERT(!(features() & Feature::MultiFile), - "Text::AbstractFontConverter::importGlyphCacheFromData(): feature advertised but not implemented", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromData(): feature advertised but not implemented", {}); CORRADE_ASSERT(data.size() == 1, - "Text::AbstractFontConverter::importGlyphCacheFromData(): expected just one file for single-file format", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromData(): expected just one file for single-file format", {}); return doImportGlyphCacheFromSingleData(data[0].second); } std::unique_ptr AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayReference data) const { CORRADE_ASSERT(features() >= (Feature::ImportGlyphCache|Feature::ConvertData), - "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature not supported", {}); CORRADE_ASSERT(!(features() & Feature::MultiFile), - "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): the format is not single-file", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): the format is not single-file", {}); return doImportGlyphCacheFromSingleData(data); } std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromSingleData(Containers::ArrayReference) const { CORRADE_ASSERT(false, - "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature advertised but not implemented", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature advertised but not implemented", {}); } std::unique_ptr AbstractFontConverter::importGlyphCacheFromFile(const std::string& filename) const { CORRADE_ASSERT(features() & Feature::ImportGlyphCache, - "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromFile(): feature not supported", {}); return doImportGlyphCacheFromFile(filename); } std::unique_ptr AbstractFontConverter::doImportGlyphCacheFromFile(const std::string& filename) const { CORRADE_ASSERT(features() & Feature::ConvertData && !(features() & Feature::MultiFile), - "Text::AbstractFontConverter::importGlyphCacheFromFile(): not implemented", nullptr); + "Text::AbstractFontConverter::importGlyphCacheFromFile(): not implemented", {}); /* Open file */ std::ifstream in(filename.data(), std::ios::binary); if(!in.good()) { Error() << "Trade::AbstractFontConverter::importGlyphCacheFromFile(): cannot open file" << filename; - return nullptr; + return {}; } /* Create array to hold file contents */ diff --git a/src/Text/Test/AbstractFontConverterTest.cpp b/src/Text/Test/AbstractFontConverterTest.cpp index 9cf1d7dfe..b3bc79f78 100644 --- a/src/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Text/Test/AbstractFontConverterTest.cpp @@ -240,7 +240,7 @@ class SingleGlyphCacheDataImporter: public Text::AbstractFontConverter { std::unique_ptr doImportGlyphCacheFromSingleData(const Containers::ArrayReference data) const override { if(data.size() == 1 && data[0] == 0xa5) return std::unique_ptr(reinterpret_cast(0xdeadbeef)); - return nullptr; + return {}; } }; diff --git a/src/Text/Test/AbstractFontTest.cpp b/src/Text/Test/AbstractFontTest.cpp index 4f007142e..30c6ff198 100644 --- a/src/Text/Test/AbstractFontTest.cpp +++ b/src/Text/Test/AbstractFontTest.cpp @@ -65,7 +65,7 @@ class SingleDataFont: public Text::AbstractFont { Vector2 doGlyphAdvance(UnsignedInt) override { return {}; } std::unique_ptr doLayout(const GlyphCache&, Float, const std::string&) override { - return nullptr; + return {}; } bool opened;