Fix bug with bookmarks loading.

This commit is contained in:
vng 2012-12-17 20:04:20 +03:00 committed by Alex Zolotarev
parent 362a283c93
commit a4a7b15b6c
2 changed files with 40 additions and 2 deletions

View file

@ -231,7 +231,7 @@ namespace bookmark_impl
else if (currTag == "description")
m_description = value;
}
else if (count > 3 && m_tags[2] == "Placemark")
else if (count > 3 && m_tags[count-3] == "Placemark")
{
if (prevTag == "Point")
{
@ -265,7 +265,8 @@ void BookmarkCategory::LoadFromKML(ReaderPtr<Reader> const & reader)
{
ReaderSource<ReaderPtr<Reader> > src(reader);
bookmark_impl::KMLParser parser(*this);
ParseXML(src, parser, true);
if (!ParseXML(src, parser, true))
LOG(LERROR, ("XML read error. Probably, incorrect file encoding."));
}
BookmarkCategory * BookmarkCategory::CreateFromKMLFile(string const & file)

View file

@ -415,3 +415,40 @@ UNIT_TEST(Bookmarks_AddingMoving)
DeleteCategoryFiles();
}
namespace
{
char const * kmlString2 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<kml xmlns=\"http://earth.google.com/kml/2.1\">"
"<Document>"
"<name>busparkplatz</name>"
"<Folder>"
"<name>Waypoint</name>"
"<Style id=\"poiIcon37\">"
"<IconStyle>"
"<scale>1</scale>"
"<Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href></Icon>"
"<hotSpot x=\"0.5\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>"
"</IconStyle>"
"</Style>"
"<Placemark>"
"<name>[P] Silvrettastrae[Bieler Hhe]</name>"
"<description></description>"
"<styleUrl>#poiIcon37</styleUrl>"
"<Point>"
"<coordinates>10.09237,46.91741,0</coordinates>"
"</Point>"
"</Placemark>"
"</Folder>"
"</Document>"
"</kml>";
}
UNIT_TEST(Bookmarks_InnerFolder)
{
BookmarkCategory cat("Default");
cat.LoadFromKML(new MemReader(kmlString2, strlen(kmlString2)));
TEST_EQUAL(cat.GetBookmarksCount(), 1, ());
}