From 3de1b45b62168b39824a6311344ded0edcf04cf3 Mon Sep 17 00:00:00 2001 From: uruk Date: Thu, 5 Sep 2013 13:29:16 +0200 Subject: AVALANCHE: Repair memory leaks in Dropdown. --- engines/avalanche/dropdown2.cpp | 6 +++++- engines/avalanche/lucerna2.cpp | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp index 53357691b9..793fc91114 100644 --- a/engines/avalanche/dropdown2.cpp +++ b/engines/avalanche/dropdown2.cpp @@ -762,6 +762,7 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it... if (_activeMenuItem._activeNow) { _activeMenuItem.wipe(); _vm->_lucerna->holdLeftMouse = false; + backup.free(); return; } // No "else"- clicking on menu has no effect (only releasing). } @@ -775,6 +776,7 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it... if (((_activeMenuItem._left * 8) <= cursorPos.x) && (cursorPos.x <= (_activeMenuItem._left * 8 + 80))) { // 80: the width of one menu item on the bar in pixels. // If we clicked on the same menu item (the one that is already active) on the bar... _vm->_lucerna->holdLeftMouse = false; + backup.free(); return; } else { _vm->_lucerna->holdLeftMouse = true; @@ -800,8 +802,10 @@ void Dropdown::updateMenu() { // TODO: Optimize it ASAP!!! It really needs it... uint16 which = (cursorPos.y - 26) / 20; _activeMenuItem.select(which); - if (_activeMenuItem._options[which]._valid) // If the menu item wasn't active, we do nothing. + if (_activeMenuItem._options[which]._valid) { // If the menu item wasn't active, we do nothing. + backup.free(); return; + } } } diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index 4673a5f195..4c9997e091 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -58,8 +58,8 @@ Lucerna::Lucerna(AvalancheEngine *vm) : fxhidden(false) { } Lucerna::~Lucerna() { - for (byte i = 0; i < 31; i++) - for (byte j = 0; j < 2; j++) + for (int i = 0; i < 31; i++) + for (int j = 0; j < 2; j++) delete _vm->_gyro->also[i][j]; } -- cgit v1.2.3