diff options
-rw-r--r-- | graphics/cursorman.cpp | 18 | ||||
-rw-r--r-- | graphics/cursorman.h | 8 | ||||
-rw-r--r-- | gui/newgui.cpp | 4 |
3 files changed, 29 insertions, 1 deletions
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index ba7c6dee9b..fe5f653b94 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -83,6 +83,24 @@ void CursorManager::popCursor() { g_system->showMouse(isVisible()); } + +void CursorManager::popAllCursors() { + while (!_cursorStack.empty()) { + Cursor *cur = _cursorStack.pop(); + delete cur; + } + + if (g_system->hasFeature(OSystem::kFeatureCursorHasPalette)) { + while (!_cursorPaletteStack.empty()) { + Palette *pal = _cursorPaletteStack.pop(); + delete pal; + } + } + + g_system->showMouse(isVisible()); +} + + void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { if (_cursorStack.empty()) { pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); diff --git a/graphics/cursorman.h b/graphics/cursorman.h index 151038e118..bf05ab762b 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -80,6 +80,14 @@ public: void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1); /** + * Pop all of the cursors and cursor palettes from their respective stacks. + * The purpose is to ensure that all unecessary cursors are removed from the + * stack when returning to the launcher from an engine. + * + */ + void popAllCursors(); + + /** * Enable/Disable the current cursor palette. * * @param disable diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 0bf61d084f..ddb69853f1 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -364,7 +364,9 @@ void NewGui::restoreState() { void NewGui::openDialog(Dialog *dialog) { _dialogStack.push(dialog); _needRedraw = true; - + + CursorMan.popAllCursors(); + // We reflow the dialog just before opening it. If the screen changed // since the last time we looked, also refresh the loaded theme, // and reflow all other open dialogs, too. |