diff options
author | Peter Kohaut | 2017-03-20 00:30:41 +0100 |
---|---|---|
committer | Peter Kohaut | 2017-03-20 00:30:41 +0100 |
commit | 02185fbcf52a406fb6a381ccfdfdd46077c24127 (patch) | |
tree | c29431a4344664c27862d43967d1c9e9f3627ea6 /gui/gui-manager.cpp | |
parent | 25e5143f99dab91d53eb52de703ef1b4c9ee2656 (diff) | |
parent | 89d5eeaa5819c10266160fd1bf12f88f6e073a12 (diff) | |
download | scummvm-rg350-02185fbcf52a406fb6a381ccfdfdd46077c24127.tar.gz scummvm-rg350-02185fbcf52a406fb6a381ccfdfdd46077c24127.tar.bz2 scummvm-rg350-02185fbcf52a406fb6a381ccfdfdd46077c24127.zip |
Merge branch 'master' of https://github.com/scummvm/scummvm
Diffstat (limited to 'gui/gui-manager.cpp')
-rw-r--r-- | gui/gui-manager.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index d28a0df8c2..76f557711d 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -254,6 +254,23 @@ Dialog *GuiManager::getTopDialog() const { return _dialogStack.top(); } +void GuiManager::addToTrash(GuiObject* object, Dialog* parent) { + debug(7, "Adding Gui Object %p to trash", (void *)object); + GuiObjectTrashItem t; + t.object = object; + t.parent = 0; + // If a dialog was provided, check it is in the dialog stack + if (parent != 0) { + for (uint i = 0 ; i < _dialogStack.size() ; ++i) { + if (_dialogStack[i] == parent) { + t.parent = parent; + break; + } + } + } + _guiObjectTrash.push_back(t); +} + void GuiManager::runLoop() { Dialog * const activeDialog = getTopDialog(); bool didSaveState = false; @@ -328,11 +345,11 @@ void GuiManager::runLoop() { // triggered in 3x mode or when running ScummVM under Valgrind.) if (activeDialog != getTopDialog() && event.type != Common::EVENT_SCREEN_CHANGED) { processEvent(event, getTopDialog()); - continue; + continue; } - + processEvent(event, activeDialog); - + if (lastRedraw + waitTime < _system->getMillis(true)) { lastRedraw = _system->getMillis(true); @@ -341,6 +358,17 @@ void GuiManager::runLoop() { } } + // Delete GuiObject that have been added to the trash for a delayed deletion + Common::List<GuiObjectTrashItem>::iterator it = _guiObjectTrash.begin(); + while (it != _guiObjectTrash.end()) { + if ((*it).parent == 0 || (*it).parent == activeDialog) { + debug(7, "Delayed deletion of Gui Object %p", (void *)(*it).object); + delete (*it).object; + it = _guiObjectTrash.erase(it); + } else + ++it; + } + if (_lastMousePosition.time + kTooltipDelay < _system->getMillis(true)) { Widget *wdg = activeDialog->findWidget(_lastMousePosition.x, _lastMousePosition.y); if (wdg && wdg->hasTooltip() && !(wdg->getFlags() & WIDGET_PRESSED)) { |