Bug fix: Widget removal from dialog now handled properly

svn-id: r33841
This commit is contained in:
Stephen Kennedy 2008-08-13 19:16:04 +00:00
parent 17c1dba992
commit 6b638f0e58

View file

@ -80,12 +80,12 @@ int Dialog::runModal() {
} }
void Dialog::open() { void Dialog::open() {
Widget *w = _firstWidget;
_result = 0; _result = 0;
_visible = true; _visible = true;
g_gui.openDialog(this); g_gui.openDialog(this);
Widget *w = _firstWidget;
// Search for the first objects that wantsFocus() (if any) and give it the focus // Search for the first objects that wantsFocus() (if any) and give it the focus
while (w && !w->wantsFocus()) { while (w && !w->wantsFocus()) {
w = w->_next; w = w->_next;
@ -331,14 +331,18 @@ void Dialog::removeWidget(Widget *del) {
Widget *w = _firstWidget; Widget *w = _firstWidget;
if (del == _firstWidget) { if (del == _firstWidget) {
_firstWidget = _firstWidget->_next; Widget *del_next = del->_next;
del->_next = 0;
_firstWidget = del_next;
return; return;
} }
w = _firstWidget; w = _firstWidget;
while (w) { while (w) {
if (w->_next == del) { if (w->_next == del) {
w->_next = w->_next->_next; Widget *del_next = del->_next;
del->_next = 0;
w->_next = del_next;
return; return;
} }
w = w->_next; w = w->_next;