Skip to content

Commit

Permalink
fixed nuiRadioButton::GetGroup
Browse files Browse the repository at this point in the history
fixed crash when adding an empty cell (a null widget) to an nui*Box
  • Loading branch information
meeloo committed Jan 28, 2014
1 parent 271f23c commit 7777f9d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion include/nuiRadioButton.h
Expand Up @@ -27,7 +27,7 @@ class nuiRadioButton : public nuiToggleButton
virtual ~nuiRadioButton();

void SetGroup(const nglString& rGroupName);
const nglString& GetGroup();
nglString GetGroup() const;

virtual bool MouseClicked (nuiSize X, nuiSize Y, nglMouseInfo::Flags Button);
virtual bool MouseUnclicked (nuiSize X, nuiSize Y, nglMouseInfo::Flags Button);
Expand Down
19 changes: 11 additions & 8 deletions src/Layout/nuiHBox.cpp
Expand Up @@ -264,16 +264,19 @@ void nuiHBox::AddCell(uint32 pos, nuiWidget* pWidget, nuiPosition position)

nuiGrid::SetCell(pos, 0, pWidget, position);

const char* props[] = { "Expand", "MaxGrow", "MaxPixels", "MinPixels", "MaxShrink", "Pixels", nullptr };
const char* attribs[] = { "CellExpand", "CellMaxGrow", "CellMaxPixels", "CellMinPixels", "CellMaxShrink", "CellPixels", nullptr };
for (int i = 0; props[i]; i++)
if (pWidget)
{
nglString val = pWidget->GetProperty(props[i]);
if (!val.IsNull())
const char* props[] = { "Expand", "MaxGrow", "MaxPixels", "MinPixels", "MaxShrink", "Pixels", nullptr };
const char* attribs[] = { "CellExpand", "CellMaxGrow", "CellMaxPixels", "CellMinPixels", "CellMaxShrink", "CellPixels", nullptr };
for (int i = 0; props[i]; i++)
{
nuiAttribBase attrib(GetAttribute(attribs[i]));
if (attrib.IsValid() && !attrib.IsReadOnly())
attrib.FromString(pos, val);
nglString val = pWidget->GetProperty(props[i]);
if (!val.IsNull())
{
nuiAttribBase attrib(GetAttribute(attribs[i]));
if (attrib.IsValid() && !attrib.IsReadOnly())
attrib.FromString(pos, val);
}
}
}
}
Expand Down
19 changes: 11 additions & 8 deletions src/Layout/nuiVBox.cpp
Expand Up @@ -266,16 +266,19 @@ void nuiVBox::AddCell(uint32 pos, nuiWidget* pWidget, nuiPosition position)

nuiGrid::SetCell(0, pos, pWidget, position);

const char* props[] = { "Expand", "MaxGrow", "MaxPixels", "MinPixels", "MaxShrink", "Pixels", nullptr };
const char* attribs[] = { "CellExpand", "CellMaxGrow", "CellMaxPixels", "CellMinPixels", "CellMaxShrink", "CellPixels", nullptr };
for (int i = 0; props[i]; i++)
if (pWidget)
{
nglString val = pWidget->GetProperty(props[i]);
if (!val.IsNull())
const char* props[] = { "Expand", "MaxGrow", "MaxPixels", "MinPixels", "MaxShrink", "Pixels", nullptr };
const char* attribs[] = { "CellExpand", "CellMaxGrow", "CellMaxPixels", "CellMinPixels", "CellMaxShrink", "CellPixels", nullptr };
for (int i = 0; props[i]; i++)
{
nuiAttribBase attrib(GetAttribute(attribs[i]));
if (attrib.IsValid() && !attrib.IsReadOnly())
attrib.FromString(pos, val);
nglString val = pWidget->GetProperty(props[i]);
if (!val.IsNull())
{
nuiAttribBase attrib(GetAttribute(attribs[i]));
if (attrib.IsValid() && !attrib.IsReadOnly())
attrib.FromString(pos, val);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/SimpleWidgets/nuiButton.cpp
Expand Up @@ -10,7 +10,7 @@
#define INACTIVE_SHADE_SIZE 8.f

#ifdef _UIKIT_
static const int DEFAULT_ACTIVATION_OFFSET = 15;
static const int DEFAULT_ACTIVATION_OFFSET = 20;
#else
static const int DEFAULT_ACTIVATION_OFFSET = 0;
#endif
Expand Down
22 changes: 11 additions & 11 deletions src/SimpleWidgets/nuiRadioButton.cpp
Expand Up @@ -10,35 +10,35 @@
nuiRadioButton::nuiRadioButton()
: nuiToggleButton()
{
SetObjectClass(_T("nuiRadioButton"));
SetGroup(_T("Default"));
SetObjectClass("nuiRadioButton");
SetGroup("Default");
mpGroupManager = NULL;
mCanToggle = false;
}

nuiRadioButton::nuiRadioButton(const nglString& rText)
: nuiToggleButton(rText)
{
SetObjectClass(_T("nuiRadioButton"));
SetGroup(_T("Default"));
SetObjectClass("nuiRadioButton");
SetGroup("Default");
mpGroupManager = NULL;
mCanToggle = false;
}

nuiRadioButton::nuiRadioButton(nuiStateDecoration* pDecoration)
: nuiToggleButton(pDecoration)
{
SetObjectClass(_T("nuiRadioButton"));
SetGroup(_T("Default"));
SetObjectClass("nuiRadioButton");
SetGroup("Default");
mpGroupManager = NULL;
mCanToggle = false;
}

nuiRadioButton::nuiRadioButton(const nglImage& rImage)
: nuiToggleButton(rImage)
{
SetObjectClass(_T("nuiRadioButton"));
SetGroup(_T("Default"));
SetObjectClass("nuiRadioButton");
SetGroup("Default");
mpGroupManager = NULL;
mCanToggle = false;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ bool nuiRadioButton::MouseMoved(nuiSize X, nuiSize Y)

void nuiRadioButton::SetGroup(const nglString& rGroupName)
{
SetProperty(_T("Group"), rGroupName);
SetProperty("Group", rGroupName);
}

void nuiRadioButton::SetGroupManager(nuiRadioButtonGroup* pGroup)
Expand All @@ -211,9 +211,9 @@ nuiRadioButtonGroup* nuiRadioButton::GetGroupManager()
return mpGroupManager;
}

const nglString& nuiRadioButton::GetGroup()
nglString nuiRadioButton::GetGroup() const
{
return GetProperty(_T("Group"));
return GetProperty("Group");
}


Expand Down
2 changes: 1 addition & 1 deletion src/SimpleWidgets/nuiToggleButton.cpp
Expand Up @@ -98,7 +98,7 @@ bool nuiToggleButton::Draw(nuiDrawContext* pContext)
// DrawChildren(pContext);
// }
// else
if (mDisplayAsFrameBox)
if (mDisplayAsFrameBox)
{
pContext->ResetState();

Expand Down

0 comments on commit 7777f9d

Please sign in to comment.