Rewrote Window::setNextFocusable() to address a bug in the management of the search iterator. Covertiy reported bug "Undefined behavior may result; the program may crash or subtly misbehave.
In osgWidget::Window::setNextFocusable(): An invalid or past-the-end iterator is being used."
This commit is contained in:
parent
d3f5aef5ef
commit
02eb8de191
@ -758,25 +758,28 @@ bool Window::setFirstFocusable() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::setNextFocusable() {
|
bool Window::setNextFocusable()
|
||||||
|
{
|
||||||
WidgetList focusList;
|
WidgetList focusList;
|
||||||
|
|
||||||
if(!getFocusList(focusList)) return false;
|
if(!getFocusList(focusList)) return false;
|
||||||
|
|
||||||
WidgetList::iterator w = focusList.begin();
|
|
||||||
|
|
||||||
// TODO: This needs to be a more complicated object, since the focus may be
|
// TODO: This needs to be a more complicated object, since the focus may be
|
||||||
// in a child Window instead of a Widget.
|
// in a child Window instead of a Widget.
|
||||||
unsigned int focusedIndex = 0;
|
WidgetList::iterator witr;
|
||||||
|
for(witr = focusList.begin();
|
||||||
for(unsigned int i = 0; w != focusList.end(); w++, i++) if(*w == _focused) {
|
witr != focusList.end();
|
||||||
focusedIndex = i;
|
++witr)
|
||||||
|
{
|
||||||
break;
|
if (*witr==_focused)
|
||||||
|
{
|
||||||
|
// found current focused widget, move to next widget the one we want to focus on
|
||||||
|
++witr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(focusedIndex < focusList.size() - 1) _setFocused((++w)->get());
|
if (witr!=focusList.end()) _setFocused(witr->get());
|
||||||
|
|
||||||
else _setFocused(focusList.front().get());
|
else _setFocused(focusList.front().get());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user