Browse Source

Fix confusing `xml->push` in one method and `xml->pop` in another

master
Krisjanis Rijnieks 10 years ago
parent
commit
d1f483899b
  1. 18
      src/Application/SettingsLoader.cpp

18
src/Application/SettingsLoader.cpp

@ -69,9 +69,13 @@ bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, st
xmlSettings->popTag(); // source xmlSettings->popTag(); // source
} }
int vertexCount = 0;
if(xmlSettings->tagExists("vertices", 0)){ if(xmlSettings->tagExists("vertices", 0)){
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
int vertexCount = xmlSettings->getNumTags("vertex"); vertexCount = xmlSettings->getNumTags("vertex");
xmlSettings->popTag(); // vertices
}
if(vertexCount == 3){ if(vertexCount == 3){
BaseSurface * triangleSurface = getTriangleSurface(xmlSettings); BaseSurface * triangleSurface = getTriangleSurface(xmlSettings);
@ -87,10 +91,6 @@ bool SettingsLoader::load(SurfaceStack & surfaces, MediaServer & mediaServer, st
surfaces.push_back(quadSurface); surfaces.push_back(quadSurface);
} }
//xmlSettings->popTag(); // vertices
// this is done in getTriangleSurface and getQuadSurface
}
xmlSettings->popTag(); // surface xmlSettings->popTag(); // surface
} }
} }
@ -171,6 +171,9 @@ bool SettingsLoader::save(SurfaceStack & surfaces, string fileName){
BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices; vector <ofVec2f> vertices;
if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices");
if(xmlSettings->tagExists("vertex", 0)){ if(xmlSettings->tagExists("vertex", 0)){
xmlSettings->pushTag("vertex", 0); xmlSettings->pushTag("vertex", 0);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
@ -193,6 +196,7 @@ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
} }
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords; vector <ofVec2f> texCoords;
@ -236,6 +240,9 @@ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices; vector <ofVec2f> vertices;
if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices");
if(xmlSettings->tagExists("vertex", 0)){ if(xmlSettings->tagExists("vertex", 0)){
xmlSettings->pushTag("vertex", 0); xmlSettings->pushTag("vertex", 0);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f), vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
@ -265,6 +272,7 @@ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
} }
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords; vector <ofVec2f> texCoords;

Loading…
Cancel
Save