diff options
author | Bastien Bouclet | 2019-11-10 14:50:18 +0100 |
---|---|---|
committer | Bastien Bouclet | 2019-11-10 20:05:04 +0100 |
commit | bd3f1574648732f7f22f7e8ce74de624c93d129c (patch) | |
tree | 949539005d4e6fe95a56844d2af29a9ab550d60a | |
parent | 416ab05eaa0bec3939629d5716803ab207eed8b1 (diff) | |
download | scummvm-rg350-bd3f1574648732f7f22f7e8ce74de624c93d129c.tar.gz scummvm-rg350-bd3f1574648732f7f22f7e8ce74de624c93d129c.tar.bz2 scummvm-rg350-bd3f1574648732f7f22f7e8ce74de624c93d129c.zip |
GUI: Fix memory leak in the about dialog
Also don't eagerly allocate EE as it consumes quite a bit of memory.
-rw-r--r-- | gui/about.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/gui/about.cpp b/gui/about.cpp index eaafadba08..6549732401 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -38,13 +38,7 @@ class EE; class EEHandler { public: - EEHandler(); - ~EEHandler(); - bool handleKeyDown(Common::KeyState &state); - -private: - EE *_ee; }; enum { @@ -146,8 +140,6 @@ AboutDialog::AboutDialog() for (i = 0; i < ARRAYSIZE(credits); i++) addLine(credits[i]); - - _eeHandler = new EEHandler; } void AboutDialog::addLine(const char *str) { @@ -296,7 +288,9 @@ void AboutDialog::handleMouseUp(int x, int y, int button, int clickCount) { } void AboutDialog::handleKeyDown(Common::KeyState state) { - if (_eeHandler->handleKeyDown(state)) { + EEHandler eeHandler; + + if (eeHandler.handleKeyDown(state)) { reflowLayout(); return; } @@ -430,17 +424,11 @@ private: void drawStatus(Common::String str, int x, uint32 color, int y = 0, int color2 = 0, int w = 16); }; -EEHandler::EEHandler() { - _ee = new EE; -} - -EEHandler::~EEHandler() { - delete _ee; -} - bool EEHandler::handleKeyDown(Common::KeyState &state) { if (state.ascii == 'v') { - _ee->run(); + EE *ee = new EE(); + ee->run(); + delete ee; g_gui.redrawFull(); |