Skip to content

Commit

Permalink
KYRA: (EOB) - fix mem leak
Browse files Browse the repository at this point in the history
  • Loading branch information
athrxx authored and Johannes Schickel committed Dec 26, 2011
1 parent 1cbd566 commit 532f8f3
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 147 deletions.
2 changes: 1 addition & 1 deletion engines/kyra/eobcommon.h
Expand Up @@ -71,7 +71,6 @@ struct EobGuiButtonDef {
uint8 y;
uint16 w;
uint8 h;
Button::Callback buttonCallback;
uint16 arg;
};

Expand Down Expand Up @@ -738,6 +737,7 @@ friend class CharacterGenerator;
int _buttonList8Size;

const EobGuiButtonDef *_buttonDefs;

const char *const *_characterGuiStringsHp;
const char *const *_characterGuiStringsWp;
const char *const *_characterGuiStringsWr;
Expand Down
13 changes: 6 additions & 7 deletions engines/kyra/gui_eob.cpp
Expand Up @@ -85,7 +85,6 @@ void LolEobBaseEngine::gui_drawHorizontalBarGraph(int x, int y, int w, int h, in
}

void LolEobBaseEngine::gui_initButtonsFromList(const int16 *list) {
return;
while (*list != -1)
gui_initButton(*list++);
}
Expand Down Expand Up @@ -808,13 +807,17 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) {
b->index = index + 1;

const EobGuiButtonDef *d = &_buttonDefs[index];
b->buttonCallback = _buttonCallbacks[index];

if (_flags.gameID == GI_EOB1) {
// EOB1 spellbook modifications
if (index > 60 && index < 66)
if (index > 60 && index < 66) {
d = &_buttonDefs[index + 33];
if (index == 88)
b->buttonCallback = _buttonCallbacks[index + 33];
} else if (index == 88) {
d = &_buttonDefs[index + 12];
b->buttonCallback = _buttonCallbacks[index + 12];
}
}

b->x = d->x;
Expand All @@ -830,7 +833,6 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) {
b->keyCode = d->keyCode;
b->keyCode2 = d->keyCode2;
b->arg = d->arg;
b->buttonCallback = d->buttonCallback;
}

int EobCoreEngine::clickedCharPortraitDefault(Button *button) {
Expand Down Expand Up @@ -1437,8 +1439,6 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) {
}

GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) {
//_scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0);

_menuStringsPrefsTemp = new char*[4];
memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*));

Expand Down Expand Up @@ -1601,7 +1601,6 @@ void GUI_Eob::processButton(Button *button) {
}

int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 mouseWheel) {
return 0;
_progress = 0;
uint16 in = inputFlags & 0xff;
uint16 buttonReleaseFlag = 0;
Expand Down
1 change: 0 additions & 1 deletion engines/kyra/lol.h
Expand Up @@ -561,7 +561,6 @@ friend class HistoryPlayer;
int clickedLamp(Button *button);
int clickedStatusIcon(Button *button);

Common::Array<Button::Callback> _buttonCallbacks;
const LoLButtonDef *_buttonData;
const int16 *_buttonList1;
const int16 *_buttonList2;
Expand Down
4 changes: 4 additions & 0 deletions engines/kyra/loleobbase.cpp
Expand Up @@ -149,6 +149,10 @@ LolEobBaseEngine::~LolEobBaseEngine() {
delete[] _levelDecorationData;
delete[] _levelDecorationProperties;
delete[] _levelBlockProperties;

for (Common::Array<Button::Callback>::iterator i = _buttonCallbacks.begin(); i != _buttonCallbacks.end(); ++i)
i->reset();
_buttonCallbacks.clear();
}

Common::Error LolEobBaseEngine::init() {
Expand Down
1 change: 1 addition & 0 deletions engines/kyra/loleobbase.h
Expand Up @@ -256,6 +256,7 @@ friend class TextDisplayer_Eob;

Button *_activeButtons;
Button _activeButtonData[70];
Common::Array<Button::Callback> _buttonCallbacks;
//bool _processingButtons;

uint8 _mouseClick;
Expand Down

0 comments on commit 532f8f3

Please sign in to comment.