Fixed focus-related crashes

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4233 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-12-01 20:12:13 +00:00
parent 584417910d
commit 554cad19cb
3 changed files with 20 additions and 4 deletions

View File

@ -94,6 +94,21 @@ Widget::~Widget()
}
void Widget::elementRemoved()
{
m_element = NULL;
// If any player focused this widget, unset that focus
for (int n=0; n<MAX_PLAYER_COUNT; n++)
{
if (m_player_focus[n])
{
GUIEngine::focusNothingForPlayer(n);
}
}
}
// -----------------------------------------------------------------------------
static unsigned int id_counter = 0;
static unsigned int id_counter_2 = 1000; // for items that can't be reached with keyboard navigation but can be clicked

View File

@ -92,6 +92,7 @@ namespace GUIEngine
class Widget : public SkinWidgetContainer
{
protected:
friend class EventHandler;
friend class RibbonWidget;
friend class Screen;
@ -303,7 +304,7 @@ namespace GUIEngine
/**
* Called when irrLicht widgets cleared. Forget all references to them, they're no more valid.
*/
virtual void elementRemoved() { m_element = NULL; }
virtual void elementRemoved();
};

View File

@ -327,7 +327,7 @@ void DynamicRibbonWidget::registerHoverListener(DynamicRibbonHoverListener* list
}
// -----------------------------------------------------------------------------
EventPropagation DynamicRibbonWidget::rightPressed(const int playerID)
{
{
RibbonWidget* w = getSelectedRibbon(playerID);
if (w != NULL)
{
@ -342,7 +342,7 @@ EventPropagation DynamicRibbonWidget::rightPressed(const int playerID)
getSelectedRibbon(playerID)->getSelectionText(playerID), playerID);
}
}
//std::cout << "rightpressed (dynamic ribbon)\n";
//std::cout << "rightpressed (dynamic ribbon) " << m_properties[PROP_ID] << "\n";
assert(m_rows.size() >= 1);
if (m_rows[0].m_ribbon_type == RIBBON_TOOLBAR) return EVENT_BLOCK;
@ -353,7 +353,7 @@ EventPropagation DynamicRibbonWidget::rightPressed(const int playerID)
}
// -----------------------------------------------------------------------------
EventPropagation DynamicRibbonWidget::leftPressed(const int playerID)
{
{
RibbonWidget* w = getSelectedRibbon(playerID);
if (w != NULL)
{