Commit bbf770a0 authored by bitplane's avatar bitplane

Fix a crash where the root element gets selected



git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3569 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e451fa41
......@@ -85,9 +85,9 @@ void CGUIAttributeEditor::refreshAttribs()
str += "_attribute";
CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this);
// if this doesn't exist, use a string editor
if (!n)
n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", this);
// if this doesn't exist, use a string editor
if (!n)
n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", this);
if (n)
{
......
......@@ -179,10 +179,10 @@ void CGUIEditWorkspace::selectNextSibling()
{
IGUIElement* p=0;
if (!SelectedElement)
p = Parent;
else
if (SelectedElement && SelectedElement->getParent())
p = SelectedElement->getParent();
else
p = Parent;
core::list<IGUIElement*>::ConstIterator it = p->getChildren().begin();
// find selected element
......@@ -202,10 +202,10 @@ void CGUIEditWorkspace::selectPreviousSibling()
{
IGUIElement* p=0;
if (!SelectedElement)
p = Parent;
else
if (SelectedElement && SelectedElement->getParent())
p = SelectedElement->getParent();
else
p = Parent;
core::list<IGUIElement*>::ConstIterator it = p->getChildren().getLast();
// find selected element
......@@ -469,7 +469,10 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
setSelectedElement(0);
// move
core::position2d<s32> p = sel->getParent()->getAbsolutePosition().UpperLeftCorner;
core::position2d<s32> p(0,0);
if (sel->getParent())
p = sel->getParent()->getAbsolutePosition().UpperLeftCorner;
sel->setRelativePosition(SelectedArea - p);
// select
......@@ -645,7 +648,8 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
CurrentMode = EGUIEDM_SELECT_NEW_PARENT;
break;
case EGUIEDMC_BRING_TO_FRONT:
SelectedElement->getParent()->bringToFront(SelectedElement);
if (SelectedElement->getParent())
SelectedElement->getParent()->bringToFront(SelectedElement);
break;
case EGUIEDMC_SAVE_ELEMENT:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment