Skip to content

Commit 5e2706e

Browse files
author
Davide Faconti
committed
bug fix for model-less XML
1 parent 7634b58 commit 5e2706e

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

bt_editor/XML_utilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ TreeNodeModels ReadTreeNodesModel(const tinyxml2::XMLElement* root)
9191
std::function<void(const XMLElement*)> recursiveStep;
9292
recursiveStep = [&](const XMLElement* node)
9393
{
94-
auto model = buildTreeNodeModel(node, true);
94+
auto model = buildTreeNodeModel(node, false);
9595
models.insert( {model.registration_ID, model} );
9696

9797
for( const XMLElement* child = node->FirstChildElement();

test/editor_test.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ private slots:
2121
void modifyCustomModel();
2222
void multipleSubtrees();
2323
void editText();
24+
void loadModelLess();
2425
};
2526

2627

@@ -47,8 +48,6 @@ void EditorTest::loadFile()
4748

4849
QString saved_xml = main_win->saveToXML();
4950

50-
std::cout << saved_xml.toStdString() << std::endl;
51-
5251
QVERIFY2( file_xml.simplified() == saved_xml.simplified(),
5352
"Loaded and saved XML are not the same" );
5453

@@ -428,6 +427,24 @@ void EditorTest::editText()
428427
sleepAndRefresh( 500 );
429428
}
430429

430+
void EditorTest::loadModelLess()
431+
{
432+
QString file_xml = readFile("://simple_without_model.xml");
433+
main_win->on_actionClear_triggered();
434+
main_win->loadFromXML( file_xml );
435+
436+
auto models = main_win->registeredModels();
437+
438+
QVERIFY( models.find("moverobot") != models.end() );
439+
440+
const auto& moverobot_model = models.at("moverobot");
441+
442+
QCOMPARE( moverobot_model.params.size(), size_t(1) );
443+
QCOMPARE( moverobot_model.params.front().label, tr("location") );
444+
QCOMPARE( moverobot_model.params.front().value, tr("1") );
445+
446+
}
447+
431448
QTEST_MAIN(EditorTest)
432449

433450
#include "editor_test.moc"

test_data/simple_without_model.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<root main_tree_to_execute="BehaviorTree">
2+
3+
<BehaviorTree ID="BehaviorTree">
4+
<SequenceStar>
5+
<Action ID="moverobot" location="1"/>
6+
</SequenceStar>
7+
</BehaviorTree>
8+
9+
</root>
10+

0 commit comments

Comments
 (0)