aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-06-03 10:48:37 +0000
committerTorbjörn Andersson2006-06-03 10:48:37 +0000
commitca84620745a134b58fb0cb102be2f50c41ca45c8 (patch)
treebe5b886293eaf659feeb8372e84c032fcf674eb6 /gui
parent3114f19d9461037ecea9ef3fd42f65dd4f8357df (diff)
downloadscummvm-rg350-ca84620745a134b58fb0cb102be2f50c41ca45c8.tar.gz
scummvm-rg350-ca84620745a134b58fb0cb102be2f50c41ca45c8.tar.bz2
scummvm-rg350-ca84620745a134b58fb0cb102be2f50c41ca45c8.zip
When the screen changes, redraw all dialogs *immediately* rather than waiting
for the main loop to check for _needRedraw. Otherwise subsequent events can cause widgets to be redrawn before the theme has had a chance to re-open the dialogs, and this could cause at least the modern theme to crash. svn-id: r22860
Diffstat (limited to 'gui')
-rw-r--r--gui/newgui.cpp54
-rw-r--r--gui/newgui.h2
2 files changed, 33 insertions, 23 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 4ad9ef45e6..f72e56fc29 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -131,6 +131,31 @@ NewGui::NewGui() : _needRedraw(false),
_theme->resetDrawArea();
}
+void NewGui::redraw() {
+ int i;
+
+ // Restore the overlay to its initial state, then draw all dialogs.
+ // This is necessary to get the blending right.
+ _theme->clearAll();
+
+ for (i = 0; i < _dialogStack.size(); ++i) {
+ _theme->closeDialog();
+ }
+ for (i = 0; i < _dialogStack.size(); i++) {
+ // Special treatment when topmost dialog has dimsInactive() set to false
+ // This is the case for PopUpWidget which should not dim a dialog
+ // which it belongs to
+ if ((i == _dialogStack.size() - 2) && !_dialogStack[i + 1]->dimsInactive())
+ _theme->openDialog(true);
+ else if ((i != (_dialogStack.size() - 1)) || !_dialogStack[i]->dimsInactive())
+ _theme->openDialog(false);
+ else
+ _theme->openDialog(true);
+
+ _dialogStack[i]->drawDialog();
+ }
+}
+
void NewGui::runLoop() {
Dialog *activeDialog = _dialogStack.top();
bool didSaveState = false;
@@ -145,7 +170,6 @@ void NewGui::runLoop() {
didSaveState = true;
}
- int i;
bool useStandardCurs = !_theme->ownCursor();
if (useStandardCurs) {
@@ -163,26 +187,7 @@ void NewGui::runLoop() {
while (!_dialogStack.empty() && activeDialog == _dialogStack.top()) {
if (_needRedraw) {
- // Restore the overlay to its initial state, then draw all dialogs.
- // This is necessary to get the blending right.
- _theme->clearAll();
-
- for (i = 0; i < _dialogStack.size(); ++i) {
- _theme->closeDialog();
- }
- for (i = 0; i < _dialogStack.size(); i++) {
- // Special treatment when topmost dialog has dimsInactive() set to false
- // This is the case for PopUpWidget which should not dim a dialog
- // which it belongs to
- if ((i == _dialogStack.size() - 2) && !_dialogStack[i + 1]->dimsInactive())
- _theme->openDialog(true);
- else if ((i != (_dialogStack.size() - 1)) || !_dialogStack[i]->dimsInactive())
- _theme->openDialog(false);
- else
- _theme->openDialog(true);
-
- _dialogStack[i]->drawDialog();
- }
+ redraw();
_needRedraw = false;
}
@@ -256,11 +261,14 @@ void NewGui::runLoop() {
case OSystem::EVENT_SCREEN_CHANGED:
// reinit the whole theme
_theme->refresh();
- _needRedraw = true;
// refresh all dialogs
- for (i = 0; i < _dialogStack.size(); ++i) {
+ for (int i = 0; i < _dialogStack.size(); ++i) {
_dialogStack[i]->handleScreenChanged();
}
+ // We need to redraw immediately. Otherwise
+ // some other event may cause a widget to be
+ // redrawn before redraw() has been called.
+ redraw();
break;
}
}
diff --git a/gui/newgui.h b/gui/newgui.h
index c41fc21c70..ccdc201062 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -120,6 +120,8 @@ protected:
void openDialog(Dialog *dialog);
void closeTopDialog();
+ void redraw();
+
void loop();
void animateCursor();