aboutsummaryrefslogtreecommitdiff
path: root/gui/gui-manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/gui-manager.cpp')
-rw-r--r--gui/gui-manager.cpp34
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)) {