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() ...@@ -85,9 +85,9 @@ void CGUIAttributeEditor::refreshAttribs()
str += "_attribute"; str += "_attribute";
CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this); CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), this);
// if this doesn't exist, use a string editor // if this doesn't exist, use a string editor
if (!n) if (!n)
n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", this); n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", this);
if (n) if (n)
{ {
......
...@@ -179,10 +179,10 @@ void CGUIEditWorkspace::selectNextSibling() ...@@ -179,10 +179,10 @@ void CGUIEditWorkspace::selectNextSibling()
{ {
IGUIElement* p=0; IGUIElement* p=0;
if (!SelectedElement) if (SelectedElement && SelectedElement->getParent())
p = Parent;
else
p = SelectedElement->getParent(); p = SelectedElement->getParent();
else
p = Parent;
core::list<IGUIElement*>::ConstIterator it = p->getChildren().begin(); core::list<IGUIElement*>::ConstIterator it = p->getChildren().begin();
// find selected element // find selected element
...@@ -202,10 +202,10 @@ void CGUIEditWorkspace::selectPreviousSibling() ...@@ -202,10 +202,10 @@ void CGUIEditWorkspace::selectPreviousSibling()
{ {
IGUIElement* p=0; IGUIElement* p=0;
if (!SelectedElement) if (SelectedElement && SelectedElement->getParent())
p = Parent;
else
p = SelectedElement->getParent(); p = SelectedElement->getParent();
else
p = Parent;
core::list<IGUIElement*>::ConstIterator it = p->getChildren().getLast(); core::list<IGUIElement*>::ConstIterator it = p->getChildren().getLast();
// find selected element // find selected element
...@@ -469,7 +469,10 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e) ...@@ -469,7 +469,10 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
setSelectedElement(0); setSelectedElement(0);
// move // 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); sel->setRelativePosition(SelectedArea - p);
// select // select
...@@ -645,7 +648,8 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e) ...@@ -645,7 +648,8 @@ bool CGUIEditWorkspace::OnEvent(const SEvent &e)
CurrentMode = EGUIEDM_SELECT_NEW_PARENT; CurrentMode = EGUIEDM_SELECT_NEW_PARENT;
break; break;
case EGUIEDMC_BRING_TO_FRONT: case EGUIEDMC_BRING_TO_FRONT:
SelectedElement->getParent()->bringToFront(SelectedElement); if (SelectedElement->getParent())
SelectedElement->getParent()->bringToFront(SelectedElement);
break; break;
case EGUIEDMC_SAVE_ELEMENT: 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