mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 10:21:31 +00:00
NGI: Plug memory leaks - bug #13071
Create a new instance of a TransparentSurface in Bitmap's copy constructor, instead of holding a reference to the original TransparentSurface. This allows to gracefully delete Bitmap's TransparentSurface when an instance of Bitmap is destroyed and resolves the memory leaks when changing rooms
This commit is contained in:
parent
53570db898
commit
1a36cda90f
@ -708,15 +708,15 @@ Bitmap::Bitmap(const Bitmap &src) {
|
||||
_type = src._type;
|
||||
_width = src._width;
|
||||
_height = src._height;
|
||||
_surface = src._surface;
|
||||
_flipping = src._flipping;
|
||||
_surface = src._surface;
|
||||
_surface = new Graphics::TransparentSurface, Graphics::SurfaceDeleter();
|
||||
_surface->create(_width, _height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
|
||||
_surface->copyFrom(*src._surface);
|
||||
}
|
||||
|
||||
Bitmap::~Bitmap() {
|
||||
// TODO: This is a hack because Graphics::Surface has terrible resource
|
||||
// management
|
||||
//_surface->free();
|
||||
_surface->free();
|
||||
delete _surface;
|
||||
}
|
||||
|
||||
void Bitmap::load(Common::ReadStream *s) {
|
||||
|
@ -161,6 +161,7 @@ void MemoryObject::loadFile(const Common::String &filename) {
|
||||
debugC(5, kDebugLoading, "Loading %s (%d bytes)", filename.c_str(), _dataSize);
|
||||
_data = (byte *)calloc(_dataSize, 1);
|
||||
s->read(_data, _dataSize);
|
||||
delete s;
|
||||
} else {
|
||||
// We have no object to read. This is fine
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user