Browse Source

GCC 4.5 compatibility: nullptr-related issues.

Vladimír Vondruš 13 years ago
parent
commit
715630b375
  1. 2
      src/Plugins/MagnumFontConverter/Test/MagnumFontConverterTest.cpp
  2. 8
      src/Plugins/TgaImageConverter/TgaImageConverter.cpp
  3. 8
      src/Plugins/WavAudioImporter/WavImporter.cpp
  4. 8
      src/Text/AbstractFont.cpp
  5. 20
      src/Text/AbstractFontConverter.cpp
  6. 2
      src/Text/Test/AbstractFontConverterTest.cpp
  7. 2
      src/Text/Test/AbstractFontTest.cpp

2
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<AbstractLayouter> doLayout(const GlyphCache&, Float, const std::string&) { return nullptr; }
std::unique_ptr<AbstractLayouter> doLayout(const GlyphCache&, Float, const std::string&) { return {}; }
UnsignedInt doGlyphId(const char32_t character) {
switch(character) {

8
src/Plugins/TgaImageConverter/TgaImageConverter.cpp

@ -60,12 +60,20 @@ Containers::Array<unsigned char> 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 */

8
src/Plugins/WavAudioImporter/WavImporter.cpp

@ -115,7 +115,13 @@ void WavImporter::doOpenData(Containers::ArrayReference<const unsigned char> 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; }

8
src/Text/AbstractFont.cpp

@ -145,19 +145,19 @@ void AbstractFont::doFillGlyphCache(GlyphCache&, const std::vector<char32_t>&)
std::unique_ptr<GlyphCache> 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<GlyphCache> 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<AbstractLayouter> 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);
}

20
src/Text/AbstractFontConverter.cpp

@ -199,52 +199,52 @@ bool AbstractFontConverter::doExportGlyphCacheToFile(GlyphCache& cache, const st
std::unique_ptr<GlyphCache> AbstractFontConverter::importGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& 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<GlyphCache> AbstractFontConverter::doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& 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<GlyphCache> AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayReference<const unsigned char> 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<GlyphCache> AbstractFontConverter::doImportGlyphCacheFromSingleData(Containers::ArrayReference<const unsigned char>) const {
CORRADE_ASSERT(false,
"Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature advertised but not implemented", nullptr);
"Text::AbstractFontConverter::importGlyphCacheFromSingleData(): feature advertised but not implemented", {});
}
std::unique_ptr<GlyphCache> 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<GlyphCache> 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 */

2
src/Text/Test/AbstractFontConverterTest.cpp

@ -240,7 +240,7 @@ class SingleGlyphCacheDataImporter: public Text::AbstractFontConverter {
std::unique_ptr<GlyphCache> doImportGlyphCacheFromSingleData(const Containers::ArrayReference<const unsigned char> data) const override {
if(data.size() == 1 && data[0] == 0xa5)
return std::unique_ptr<GlyphCache>(reinterpret_cast<GlyphCache*>(0xdeadbeef));
return nullptr;
return {};
}
};

2
src/Text/Test/AbstractFontTest.cpp

@ -65,7 +65,7 @@ class SingleDataFont: public Text::AbstractFont {
Vector2 doGlyphAdvance(UnsignedInt) override { return {}; }
std::unique_ptr<AbstractLayouter> doLayout(const GlyphCache&, Float, const std::string&) override {
return nullptr;
return {};
}
bool opened;

Loading…
Cancel
Save