From 50673f9f1fada025a0b6804b0bd17cd9262226dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Andersson?= Date: Fri, 16 Jun 2006 06:26:26 +0000 Subject: [PATCH] The top dialog can change during the event loop. In that case, flush all the dialog-related events since they were probably generated while the old dialog was still visible, and therefore note intended for the new one. This hopefully fixes strange behaviour/crashes with pop-up widgets. (Most easy to trigger in 3x mode or when running ScummVM under Valgrind.) svn-id: r23141 --- gui/newgui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 57c23e35e2a..c8fd5606910 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -201,6 +201,9 @@ void NewGui::runLoop() { uint32 time = _system->getMillis(); while (_system->pollEvent(event)) { + if (activeDialog != _dialogStack.top() && event.type != OSystem::EVENT_QUIT && event.type != OSystem::EVENT_SCREEN_CHANGED) + continue; + Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y); switch (event.type) { @@ -270,7 +273,7 @@ void NewGui::runLoop() { } // check if event should be sent again (keydown) - if (_currentKeyDown.keycode != 0) { + if (_currentKeyDown.keycode != 0 && activeDialog == _dialogStack.top()) { if (_keyRepeatTime < time) { // fire event activeDialog->handleKeyDown(_currentKeyDown.ascii, _currentKeyDown.keycode, _currentKeyDown.flags);