aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2014-08-03 11:36:56 +0200
committeruruk2014-08-03 11:36:56 +0200
commit8eae09afcac8c33ac0d7c8282001692f4f6df749 (patch)
tree64a1b994c613688c3b72cd9575f1997e86a653d5 /engines
parent239fa2a5cfee7a71b909ad338d14a54c5f44ca95 (diff)
downloadscummvm-rg350-8eae09afcac8c33ac0d7c8282001692f4f6df749.tar.gz
scummvm-rg350-8eae09afcac8c33ac0d7c8282001692f4f6df749.tar.bz2
scummvm-rg350-8eae09afcac8c33ac0d7c8282001692f4f6df749.zip
CGE2: Fix memory leak concerning the quit menu.
Diffstat (limited to 'engines')
-rw-r--r--engines/cge2/toolbar.cpp9
-rw-r--r--engines/cge2/vmenu.cpp12
-rw-r--r--engines/cge2/vmenu.h9
3 files changed, 19 insertions, 11 deletions
diff --git a/engines/cge2/toolbar.cpp b/engines/cge2/toolbar.cpp
index be9f73e5b4..5880dfce6a 100644
--- a/engines/cge2/toolbar.cpp
+++ b/engines/cge2/toolbar.cpp
@@ -129,18 +129,15 @@ void CGE2Engine::checkMusicSwitch() {
}
void CGE2Engine::quit() {
- Common::Array<Choice *> quitMenu; // Deleted in VMenu's destructor.
- quitMenu.push_back(new ExitGameChoice(this));
- quitMenu.push_back(new ReturnToGameChoice(this));
-
if (_commandHandler->idle()) {
if (VMenu::_addr) {
_commandHandlerTurbo->addCommand(kCmdKill, -1, 0, VMenu::_addr);
ReturnToGameChoice rqsChoice(this);
rqsChoice.proc();
} else {
- quitMenu[0]->_text = _text->getText(kQuitText);
- quitMenu[1]->_text = _text->getText(kNoQuitText);
+ Common::Array<Choice *> quitMenu; // Deleted in VMenu's destructor.
+ quitMenu.push_back(new ExitGameChoice(this));
+ quitMenu.push_back(new ReturnToGameChoice(this));
(new VMenu(this, quitMenu, V2D(this, -1, -1), kCBMnu))->setName(_text->getText(kQuitTitle));
_commandHandlerTurbo->addCommand(kCmdSeq, kPowerRef, 0, nullptr);
keyClick();
diff --git a/engines/cge2/vmenu.cpp b/engines/cge2/vmenu.cpp
index ceb69f099d..6afe5e9a61 100644
--- a/engines/cge2/vmenu.cpp
+++ b/engines/cge2/vmenu.cpp
@@ -25,16 +25,26 @@
* Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon
*/
-#include "cge2/cge2.h"
+#include "cge2/text.h"
#include "cge2/vmenu.h"
#include "cge2/events.h"
namespace CGE2 {
+Choice::Choice(CGE2Engine *vm) : _vm(vm), _text(nullptr) {}
+
+ExitGameChoice::ExitGameChoice(CGE2Engine *vm) : Choice(vm) {
+ _text = _vm->_text->getText(kQuitText);
+}
+
void ExitGameChoice::proc() {
_vm->switchScene(-1);
}
+ReturnToGameChoice::ReturnToGameChoice(CGE2Engine *vm) : Choice(vm) {
+ _text = _vm->_text->getText(kNoQuitText);
+}
+
void ReturnToGameChoice::proc() {
_vm->_commandHandlerTurbo->addCommand(kCmdSeq, kPowerRef, 1, nullptr);
_vm->keyClick();
diff --git a/engines/cge2/vmenu.h b/engines/cge2/vmenu.h
index e28eee74b8..60796e750a 100644
--- a/engines/cge2/vmenu.h
+++ b/engines/cge2/vmenu.h
@@ -33,6 +33,7 @@
#define kLt 3
#define kRb 1
+#include "cge2/cge2.h"
#include "cge2/talk.h"
namespace CGE2 {
@@ -42,21 +43,21 @@ protected:
CGE2Engine *_vm;
public:
char *_text;
+
virtual void proc() = 0;
- Choice(CGE2Engine *vm) : _vm(vm), _text(nullptr) {}
- virtual ~Choice() {}
+ Choice(CGE2Engine *vm);
};
class ExitGameChoice : public Choice {
public:
- ExitGameChoice(CGE2Engine *vm) : Choice(vm) {}
+ ExitGameChoice(CGE2Engine *vm);
void proc();
};
class ReturnToGameChoice : public Choice {
public:
- ReturnToGameChoice(CGE2Engine *vm) : Choice(vm) {}
+ ReturnToGameChoice(CGE2Engine *vm);
void proc();
};