Commit 1fbf4fdc authored by Bob Obara's avatar Bob Obara Committed by Kitware Robot

Merge topic 'fixingFindOnGroupItems' into release

aa1c186c BUG: doing GroupItem::find crashes on empty group items
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: John Tourtellott's avatarJohn Tourtellott <john.tourtellott@kitware.com>
Merge-request: !1608
parents 8f118402 aa1c186c
Pipeline #140131 running with stage
# Bug Fixes on Release (and Master)
* GroupItem::find - crashes when the group has no subgroups (Issue #245)
......@@ -296,7 +296,10 @@ smtk::attribute::ItemPtr GroupItem::find(
std::size_t element, const std::string& inName, SearchStyle style)
{
// Make sure element is valid
assert(m_items.size() > element);
if (m_items.size() <= element)
{
return nullptr;
}
// Lets see if we can find it in the group's items
for (auto& item : m_items[element])
......@@ -328,7 +331,10 @@ smtk::attribute::ConstItemPtr GroupItem::find(
std::size_t element, const std::string& inName, SearchStyle style) const
{
// Make sure element is valid
assert(m_items.size() > element);
if (m_items.size() <= element)
{
return nullptr;
}
// Lets see if we can find it in the group's items
for (auto& item : m_items[element])
......
......@@ -61,6 +61,12 @@ int main()
s_idef1->addConditionalItem("b-a-b", "b-a-b");
g_idef1->addItemDefinition<StringItemDefinitionPtr>("b-b-a");
// There was an issue with searching empty groups that caused a crash
// Let add one to be make sure we don't regress.
g_idef = def->addItemDefinition<GroupItemDefinitionPtr>("empty");
g_idef->setIsExtensible(true);
g_idef->setNumberOfRequiredGroups(0);
// Ok now create an attribute
AttributePtr att = resource->createAttribute("testAtt", "testDef");
......
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