diff options
| -rw-r--r-- | engines/engine.cpp | 21 | ||||
| -rw-r--r-- | engines/kyra/screen.cpp | 3 | ||||
| -rw-r--r-- | engines/scumm/scumm.cpp | 10 |
3 files changed, 19 insertions, 15 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index 8487a42d05..b7d2c40344 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -30,6 +30,9 @@ #endif #include "engines/engine.h" +#include "engines/dialogs.h" +#include "engines/metaengine.h" + #include "common/config-manager.h" #include "common/debug.h" #include "common/events.h" @@ -37,12 +40,14 @@ #include "common/timer.h" #include "common/savefile.h" #include "common/system.h" + #include "gui/debugger.h" #include "gui/message.h" #include "gui/GuiManager.h" + #include "sound/mixer.h" -#include "engines/dialogs.h" -#include "engines/metaengine.h" + +#include "graphics/cursorman.h" #ifdef _WIN32_WCE extern bool isSmartphone(); @@ -103,6 +108,14 @@ Engine::Engine(OSystem *syst) // freed. Of course, there still would be problems with many games... if (!_mixer->isReady()) warning("Sound initialization failed. This may cause severe problems in some games."); + + // Setup a dummy cursor and palette, so that all engines can use CursorMan.replace + // without having any headaches about memory leaks. Check commit log of r48620 for + // some information about this. + CursorMan.pushCursor(NULL, 0, 0, 0, 0, 0); + // Note: Using this dummy palette will actually disable cursor palettes till the + // user enables it again. + CursorMan.pushCursorPalette(NULL, 0, 0); } Engine::~Engine() { @@ -110,6 +123,10 @@ Engine::~Engine() { delete _mainMenuDialog; g_engine = NULL; + + // Remove our cursors again to prevent memory leaks + CursorMan.popCursor(); + CursorMan.popCursorPalette(); } void initCommonGFX(bool defaultTo1XScaler) { diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 0332e56e73..14463568ac 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -69,8 +69,6 @@ Screen::~Screen() { for (uint i = 0; i < _palettes.size(); ++i) delete _palettes[i]; - - CursorMan.popCursor(); } bool Screen::init() { @@ -158,7 +156,6 @@ bool Screen::init() { _animBlockPtr = NULL; _animBlockSize = 0; _mouseLockCount = 1; - CursorMan.pushCursor(NULL, 0, 0, 0, 0, 0); CursorMan.showMouse(false); _forceFullUpdate = false; diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index a24fc650a5..5555d961b2 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -550,12 +550,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) Common::addDebugChannel(debugChannels[i].flag, debugChannels[i].channel, debugChannels[i].desc); g_eventRec.registerRandomSource(_rnd, "scumm"); - - // Setup a dummy cursor and palette. The latter is only - // required by HE, thus we might consider to do that only - // for HE games. - CursorMan.pushCursor(NULL, 0, 0, 0, 0, 0); - CursorMan.pushCursorPalette(NULL, 0, 0); } @@ -612,10 +606,6 @@ ScummEngine::~ScummEngine() { delete _res; delete _gdi; - - // Remove our cursors again to prevent memory leaks - CursorMan.popCursor(); - CursorMan.popCursorPalette(); } |
