MYST3: Don't call a child class implementation from a destructor

This commit is contained in:
Bastien Bouclet 2014-09-13 11:44:19 +02:00
parent cfef964848
commit 6b29c6f1f7
4 changed files with 11 additions and 17 deletions

View File

@ -36,22 +36,17 @@ BaseRenderer::BaseRenderer(OSystem *system)
: _system(system), _font(NULL) { }
BaseRenderer::~BaseRenderer() {
if (_font)
freeTexture(_font);
}
void BaseRenderer::init() {
}
void BaseRenderer::initFont(const Graphics::Surface *surface) {
_font = createTexture(surface);
}
Texture *BaseRenderer::createTexture(const Graphics::Surface *surface) {
return NULL;
}
void BaseRenderer::freeTexture(Texture *texture) {
void BaseRenderer::freeFont() {
if (_font) {
freeTexture(_font);
_font = nullptr;
}
}
Common::Rect BaseRenderer::getFontCharacterRect(uint8 character) {

View File

@ -53,6 +53,7 @@ class Renderer {
virtual ~Renderer() {}
virtual void init() = 0;
virtual void initFont(const Graphics::Surface *surface) = 0;
virtual void freeFont() = 0;
virtual void clear() = 0;
virtual void setupCameraOrtho2D(bool noScaling) = 0;
@ -98,11 +99,8 @@ public:
BaseRenderer(OSystem *system);
virtual ~BaseRenderer();
virtual Texture *createTexture(const Graphics::Surface *surface);
virtual void freeTexture(Texture *texture);
virtual void init();
virtual void initFont(const Graphics::Surface *surface);
virtual void initFont(const Graphics::Surface *surface) override;
virtual void freeFont() override;
Common::Rect viewport() const override;
Common::Rect frameViewport() const override;

View File

@ -51,7 +51,7 @@ public:
float transparency = -1.0, bool additiveBlending = false) override;
virtual void drawTexturedRect3D(const Math::Vector3d &topLeft, const Math::Vector3d &bottomLeft,
const Math::Vector3d &topRight, const Math::Vector3d &bottomRight,
Texture *texture);
Texture *texture) override;
virtual void drawCube(Texture **textures) override;
virtual void draw2DText(const Common::String &text, const Common::Point &position) override;
@ -60,7 +60,7 @@ public:
virtual void screenPosToDirection(const Common::Point screen, float &pitch, float &heading) override;
virtual void flipBuffer();
virtual void flipBuffer() override;
private:
void drawFace(uint face, Texture *texture);

View File

@ -209,6 +209,7 @@ Common::Error Myst3Engine::run() {
unloadNode();
_archiveNode->close();
_gfx->freeFont();
// Make sure the mouse is unlocked
_system->lockMouse(false);