From e12d010c45f1264ae5dbf281367e80b1f3abce17 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 16 May 2005 15:37:30 +0000 Subject: [PATCH] Added a Dialog::reset() method, which basically makes sure that any dialog boxes are in a known, closed state. Simply calling Dialog::close() on those dialog boxes *should* have done the trick, but it occasionally results in a segfault. My code doesn't ;) It's probably a hack, but it's a small and necessary one at this point. When I eventually run Stella through Valgrind, I'll probably find the segfault is caused by a dangling pointer or something ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@426 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/gui/Dialog.cxx | 8 +++++++- stella/src/gui/Dialog.hxx | 7 ++++--- stella/src/gui/DialogContainer.cxx | 11 +++++------ stella/src/gui/LauncherDialog.cxx | 8 +++++++- stella/src/gui/LauncherDialog.hxx | 3 ++- stella/src/gui/OptionsDialog.cxx | 13 ++++++++++++- stella/src/gui/OptionsDialog.hxx | 3 ++- 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/stella/src/gui/Dialog.cxx b/stella/src/gui/Dialog.cxx index 6a307c9ab..452f6ce19 100644 --- a/stella/src/gui/Dialog.cxx +++ b/stella/src/gui/Dialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Dialog.cxx,v 1.14 2005-05-13 18:28:05 stephena Exp $ +// $Id: Dialog.cxx,v 1.15 2005-05-16 15:37:30 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -89,6 +89,12 @@ void Dialog::close() releaseFocus(); parent()->removeDialog(); + reset(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::reset() +{ _openCount = 0; } diff --git a/stella/src/gui/Dialog.hxx b/stella/src/gui/Dialog.hxx index b070065d1..cc463c2de 100644 --- a/stella/src/gui/Dialog.hxx +++ b/stella/src/gui/Dialog.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Dialog.hxx,v 1.12 2005-05-13 18:28:05 stephena Exp $ +// $Id: Dialog.hxx,v 1.13 2005-05-16 15:37:30 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -35,7 +35,7 @@ class DialogContainer; This is the base class for all dialog boxes. @author Stephen Anthony - @version $Id: Dialog.hxx,v 1.12 2005-05-13 18:28:05 stephena Exp $ + @version $Id: Dialog.hxx,v 1.13 2005-05-16 15:37:30 stephena Exp $ */ class Dialog : public GuiObject { @@ -51,6 +51,7 @@ class Dialog : public GuiObject virtual void open(); virtual void close(); + virtual void reset(); virtual void drawDialog(); virtual void loadConfig() {} virtual void saveConfig() {} @@ -82,7 +83,7 @@ class Dialog : public GuiObject Widget* _focusedWidget; Widget* _dragWidget; bool _visible; - int _openCount; + int _openCount; private: int _result; diff --git a/stella/src/gui/DialogContainer.cxx b/stella/src/gui/DialogContainer.cxx index e0c3c9397..3121ca918 100644 --- a/stella/src/gui/DialogContainer.cxx +++ b/stella/src/gui/DialogContainer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DialogContainer.cxx,v 1.4 2005-05-16 00:02:32 stephena Exp $ +// $Id: DialogContainer.cxx,v 1.5 2005-05-16 15:37:30 stephena Exp $ //============================================================================ #include "OSystem.hxx" @@ -72,13 +72,12 @@ void DialogContainer::removeDialog() void DialogContainer::reStack() { // Pop all items from the stack, and then add the base menu - Dialog* d; while(!myDialogStack.empty()) - { - d = myDialogStack.pop(); - d->close(); - } + myDialogStack.pop(); myDialogStack.push(myBaseDialog); + + // Now make sure all dialog boxes are in a known (closed) state + myBaseDialog->reset(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/LauncherDialog.cxx b/stella/src/gui/LauncherDialog.cxx index 42b387cbd..184b4ce47 100644 --- a/stella/src/gui/LauncherDialog.cxx +++ b/stella/src/gui/LauncherDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: LauncherDialog.cxx,v 1.13 2005-05-14 03:26:29 stephena Exp $ +// $Id: LauncherDialog.cxx,v 1.14 2005-05-16 15:37:30 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -161,6 +161,12 @@ void LauncherDialog::close() */ } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void LauncherDialog::reset() +{ + myOptions->reset(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherDialog::updateListing(bool fullReload) { diff --git a/stella/src/gui/LauncherDialog.hxx b/stella/src/gui/LauncherDialog.hxx index ef9f59b88..a5f7b9f33 100644 --- a/stella/src/gui/LauncherDialog.hxx +++ b/stella/src/gui/LauncherDialog.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: LauncherDialog.hxx,v 1.6 2005-05-13 18:28:05 stephena Exp $ +// $Id: LauncherDialog.hxx,v 1.7 2005-05-16 15:37:30 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -46,6 +46,7 @@ class LauncherDialog : public Dialog void updateListing(bool fullReload = false); void close(); + void reset(); void loadConfig(); protected: diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index d25de5b8d..813aa301b 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OptionsDialog.cxx,v 1.17 2005-05-16 00:02:32 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.18 2005-05-16 15:37:30 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -133,6 +133,17 @@ void OptionsDialog::checkBounds(int width, int height, *y = (height - *h) / 2; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OptionsDialog::reset() +{ + myVideoDialog->reset(); + myAudioDialog->reset(); + myEventMappingDialog->reset(); + myGameInfoDialog->reset(); + myHelpDialog->reset(); + myAboutDialog->reset(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OptionsDialog::handleCommand(CommandSender* sender, int cmd, int data) { diff --git a/stella/src/gui/OptionsDialog.hxx b/stella/src/gui/OptionsDialog.hxx index 4681693e1..a61271e49 100644 --- a/stella/src/gui/OptionsDialog.hxx +++ b/stella/src/gui/OptionsDialog.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OptionsDialog.hxx,v 1.7 2005-05-16 00:02:32 stephena Exp $ +// $Id: OptionsDialog.hxx,v 1.8 2005-05-16 15:37:30 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -44,6 +44,7 @@ class OptionsDialog : public Dialog virtual void handleCommand(CommandSender* sender, int cmd, int data); + void reset(); void setGameProfile(Properties& props) { myGameInfoDialog->setGameProfile(props); } protected: