Skip to content

Commit e87c712

Browse files
author
AndyZe
committed
Improve the check by counting num async children
1 parent ff029cc commit e87c712

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/xml_parsing.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,25 @@ void VerifyXML(const std::string& xml_text,
543543
}
544544
if(name == "ReactiveSequence")
545545
{
546-
const std::string child_name = node->FirstChildElement()->Name();
547-
const auto child_search = registered_nodes.find(child_name);
548-
auto child_type = child_search->second;
549-
if(child_type == NodeType::CONTROL &&
550-
((child_name == "ThreadedAction") || (child_name == "StatefulActionNode") ||
551-
(child_name == "CoroActionNode") || (child_name == "AsyncSequence")))
546+
size_t async_count = 0;
547+
for(auto child = node->FirstChildElement(); child != nullptr;
548+
child = child->NextSiblingElement())
552549
{
553-
ThrowError(line_number, std::string("The first child of a ReactiveSequence "
554-
"cannot be asynchronous"));
550+
const std::string child_name = node->FirstChildElement()->Name();
551+
const auto child_search = registered_nodes.find(child_name);
552+
auto child_type = child_search->second;
553+
if(child_type == NodeType::CONTROL &&
554+
((child_name == "ThreadedAction") ||
555+
(child_name == "StatefulActionNode") ||
556+
(child_name == "CoroActionNode") || (child_name == "AsyncSequence")))
557+
{
558+
++async_count;
559+
if(async_count > 1)
560+
{
561+
ThrowError(line_number, std::string("A ReactiveSequence cannot have more "
562+
"than one async child."));
563+
}
564+
}
555565
}
556566
}
557567
}

0 commit comments

Comments
 (0)