Skip to content

Commit f3bd20d

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

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/xml_parsing.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,23 @@ 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") || (child_name == "StatefulActionNode") ||
555+
(child_name == "CoroActionNode") || (child_name == "AsyncSequence")))
556+
{
557+
++async_count;
558+
if (async_count > 1)
559+
{
560+
ThrowError(line_number, std::string("A ReactiveSequence cannot have more than one async child."));
561+
}
562+
}
555563
}
556564
}
557565
}

0 commit comments

Comments
 (0)