Bug Fixed: Font::render...

Bug Fixed in class Font::renderText ( and its family functions )
These functions cause exceptions while testing on Visual Studio. And we
soon found 'SDL_FreeSurface' was not used in 'reset' method of shared_ptr.
Now we have fixed it.
This commit is contained in:
Kirigaya Kazuto 2017-03-23 13:41:24 +08:00
parent 0bd9811452
commit 0ec40c6270

View File

@ -565,56 +565,56 @@ namespace MiniEngine
Texture Font::renderText(Renderer rnd, std::string Text, RGBA fg) Texture Font::renderText(Renderer rnd, std::string Text, RGBA fg)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderText_Blended(font.get(), Text.c_str(), fg.toSDLColor())); surf.surf.reset(TTF_RenderText_Blended(font.get(), Text.c_str(), fg.toSDLColor()), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderTextWrapped(Renderer rnd, std::string Text, RGBA fg, int WrapLength) Texture Font::renderTextWrapped(Renderer rnd, std::string Text, RGBA fg, int WrapLength)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderText_Blended_Wrapped(font.get(), Text.c_str(), fg.toSDLColor(), WrapLength)); surf.surf.reset(TTF_RenderText_Blended_Wrapped(font.get(), Text.c_str(), fg.toSDLColor(), WrapLength), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderTextShaded(Renderer rnd, std::string Text, RGBA fg, RGBA bg) Texture Font::renderTextShaded(Renderer rnd, std::string Text, RGBA fg, RGBA bg)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderText_Shaded(font.get(), Text.c_str(), fg.toSDLColor(), bg.toSDLColor())); surf.surf.reset(TTF_RenderText_Shaded(font.get(), Text.c_str(), fg.toSDLColor(), bg.toSDLColor()), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderTextSolid(Renderer rnd, std::string Text, RGBA fg) Texture Font::renderTextSolid(Renderer rnd, std::string Text, RGBA fg)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderText_Solid(font.get(), Text.c_str(), fg.toSDLColor())); surf.surf.reset(TTF_RenderText_Solid(font.get(), Text.c_str(), fg.toSDLColor()), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderUTF8(Renderer rnd, std::string Text, RGBA fg) Texture Font::renderUTF8(Renderer rnd, std::string Text, RGBA fg)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderUTF8_Blended(font.get(), Text.c_str(), fg.toSDLColor())); surf.surf.reset(TTF_RenderUTF8_Blended(font.get(), Text.c_str(), fg.toSDLColor()), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderUTF8Wrapped(Renderer rnd, std::string Text, RGBA fg, int WrapLength) Texture Font::renderUTF8Wrapped(Renderer rnd, std::string Text, RGBA fg, int WrapLength)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderUTF8_Blended_Wrapped(font.get(), Text.c_str(), fg.toSDLColor(), WrapLength)); surf.surf.reset(TTF_RenderUTF8_Blended_Wrapped(font.get(), Text.c_str(), fg.toSDLColor(), WrapLength), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderUTF8Shaded(Renderer rnd, std::string Text, RGBA fg, RGBA bg) Texture Font::renderUTF8Shaded(Renderer rnd, std::string Text, RGBA fg, RGBA bg)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderUTF8_Shaded(font.get(), Text.c_str(), fg.toSDLColor(), bg.toSDLColor())); surf.surf.reset(TTF_RenderUTF8_Shaded(font.get(), Text.c_str(), fg.toSDLColor(), bg.toSDLColor()), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }
Texture Font::renderUTF8Solid(Renderer rnd, std::string Text, RGBA fg) Texture Font::renderUTF8Solid(Renderer rnd, std::string Text, RGBA fg)
{ {
Surface surf; Surface surf;
surf.surf.reset(TTF_RenderUTF8_Solid(font.get(), Text.c_str(), fg.toSDLColor())); surf.surf.reset(TTF_RenderUTF8_Solid(font.get(), Text.c_str(), fg.toSDLColor()), SDL_FreeSurface);
return rnd.render(surf); return rnd.render(surf);
} }