Skip to content

Commit

Permalink
Merged in duplicate_use_parent_model_frame7 (pull request #573)
Browse files Browse the repository at this point in the history
Prevent duplicate `use_parent_model_frame` tags during file conversion

Approved-by: Addisu Z. Taddese <addisu@openrobotics.org>
Approved-by: Nate Koenig <natekoenig@gmail.com>
  • Loading branch information
scpeters committed Nov 6, 2019
2 parents 5a642bc + 29bebd2 commit b89f0d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
1. Avoid hardcoding /machine:x64 flag on 64-bit on MSVC with CMake >= 3.5.
* [Pull request 565](https://bitbucket.org/osrf/sdformat/pull-requests/565)

1. Prevent duplicate `use_parent_model_frame` tags during file conversion.
* [Pull request 573](https://bitbucket.org/osrf/sdformat/pull-requests/573)

1. Backport inline versioned namespace from version 8.
* [Pull request 557](https://bitbucket.org/osrf/sdformat/pull-requests/557)
* [pull request 464](https://bitbucket.org/osrf/sdformat/pull-requests/464)
Expand Down
2 changes: 1 addition & 1 deletion src/Converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ bool Converter::Convert(TiXmlDocument *_doc, const std::string &_toVersion,
std::map<std::string, std::pair<std::string, std::string> >::const_iterator
fromIter = conversionMap.find(origVersion);

TiXmlDocument xmlDoc;
std::string toVer = "";

// Starting with the original SDF version, perform all the conversions
Expand All @@ -92,6 +91,7 @@ bool Converter::Convert(TiXmlDocument *_doc, const std::string &_toVersion,
toVer = fromIter->second.first;

// Parse and apply the conversion XML.
TiXmlDocument xmlDoc;
xmlDoc.Parse(fromIter->second.second.c_str());
ConvertImpl(elem, xmlDoc.FirstChildElement("convert"));

Expand Down
10 changes: 10 additions & 0 deletions test/integration/joint_axis_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ TEST(JointAxisFrame, Version_1_4_missing)
axis->PrintValues("");
EXPECT_TRUE(axis->HasElement("use_parent_model_frame"));
EXPECT_TRUE(axis->Get<bool>("use_parent_model_frame"));

// count number of use_parent_model_frame elements
int elementCount = 0;
sdf::ElementPtr elem = axis->GetElement("use_parent_model_frame");
while (elem)
{
elem = elem->GetNextElement("use_parent_model_frame");
++elementCount;
}
EXPECT_EQ(1, elementCount);
}

////////////////////////////////////////
Expand Down

0 comments on commit b89f0d6

Please sign in to comment.