MaskBuffer and PathBuffer are now correctly freed before they are deallocated, and so is background Surface.

svn-id: r28483
This commit is contained in:
Nicola Mettifogo
2007-08-07 14:53:58 +00:00
parent 66c0a57248
commit d30c3650a3
5 changed files with 31 additions and 17 deletions
+13 -5
View File
@@ -772,16 +772,20 @@ void Gfx::freeStaticCnv(StaticCnv *cnv) {
void Gfx::setBackground(Graphics::Surface *surface) {
if (_buffers[kBit2])
if (_buffers[kBit2]) {
_buffers[kBit2]->free();
delete _buffers[kBit2];
}
_buffers[kBit2] = surface;
copyScreen(kBit2, kBitBack);
}
void Gfx::setMask(MaskBuffer *buffer) {
if (_depthMask)
if (_depthMask) {
_depthMask->free();
delete _depthMask;
}
_depthMask = buffer;
}
@@ -893,16 +897,20 @@ Gfx::Gfx(Parallaction* vm) :
Gfx::~Gfx() {
_depthMask->free();
delete _depthMask;
if (_depthMask) {
_depthMask->free();
delete _depthMask;
}
_buffers[kBitFront]->free();
delete _buffers[kBitFront];
_buffers[kBitBack]->free();
delete _buffers[kBitBack];
if (_buffers[kBit2])
if (_buffers[kBit2]) {
_buffers[kBit2]->free();
delete _buffers[kBit2];
}
delete _fonts[kFontDialogue];
delete _fonts[kFontLabel];
+6 -5
View File
@@ -156,11 +156,7 @@ struct MaskBuffer {
byte *data;
public:
MaskBuffer() : w(0), internalWidth(0), h(0), data(0) {
}
~MaskBuffer() {
free();
MaskBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
}
void create(uint16 width, uint16 height) {
@@ -174,6 +170,11 @@ public:
void free() {
if (data)
::free(data);
data = 0;
w = 0;
h = 0;
internalWidth = 0;
size = 0;
}
inline byte getValue(uint16 x, uint16 y) {
+3 -1
View File
@@ -131,8 +131,10 @@ Parallaction::~Parallaction() {
delete _zoneTypeNames;
delete _zoneFlagNames;
if (_pathBuffer)
if (_pathBuffer) {
_pathBuffer->free();
delete _pathBuffer;
}
_animations.remove(&_char._ani);
+3 -1
View File
@@ -422,8 +422,10 @@ void jobWalk(void *parm, Job *j) {
void Parallaction::setPath(PathBuffer *buffer) {
if (_pathBuffer)
if (_pathBuffer) {
_pathBuffer->free();
delete _pathBuffer;
}
_pathBuffer = buffer;
}
+6 -5
View File
@@ -60,11 +60,7 @@ struct PathBuffer {
byte *data;
public:
PathBuffer() : w(0), internalWidth(0), h(0), data(0) {
}
~PathBuffer() {
free();
PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
}
void create(uint16 width, uint16 height) {
@@ -78,6 +74,11 @@ public:
void free() {
if (data)
::free(data);
data = 0;
w = 0;
h = 0;
internalWidth = 0;
size = 0;
}
inline byte getValue(uint16 x, uint16 y);