[Scummvm-cvs-logs] SF.net SVN: scummvm:[33706] scummvm/branches/gsoc2008-gui/common

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Aug 8 20:48:14 CEST 2008


Revision: 33706
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33706&view=rev
Author:   Tanoku
Date:     2008-08-08 18:48:12 +0000 (Fri, 08 Aug 2008)

Log Message:
-----------
BUGFIX: XMLParser issuing key-close callbacks on ignored keys.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
    scummvm/branches/gsoc2008-gui/common/xmlparser.h

Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-08-08 18:36:13 UTC (rev 33705)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.cpp	2008-08-08 18:48:12 UTC (rev 33706)
@@ -135,7 +135,7 @@
 	}
 	
 	if (closed)
-		delete _activeKey.pop();
+		return closeKey();
 
 	return true;
 }
@@ -166,6 +166,23 @@
 	return true;
 }
 
+bool XMLParser::closeKey() {
+	bool ignore = false;
+	bool result = true;
+	
+	for (int i = _activeKey.size() - 1; i >= 0; --i) {
+		if (_activeKey[i]->ignore)
+			ignore = true;
+	}
+	
+	if (ignore == false)
+		result = closedKeyCallback(_activeKey.top());
+		
+	delete _activeKey.pop();
+	
+	return result;
+}
+
 bool XMLParser::parse() {
 
 	if (_text.ready() == false)
@@ -235,13 +252,12 @@
 
 			case kParserNeedPropertyName:
 				if (activeClosure) {
-					if (!closedKeyCallback(_activeKey.top())) {
+					if (!closeKey()) {
 						parserError("Missing data when closing key '%s'.", _activeKey.top()->name.c_str()); 
 						break;
 					}
 
 					activeClosure = false;
-					delete _activeKey.pop();
 
 					if (_text[_pos++] != '>')
 						parserError("Invalid syntax in key closure.");

Modified: scummvm/branches/gsoc2008-gui/common/xmlparser.h
===================================================================
--- scummvm/branches/gsoc2008-gui/common/xmlparser.h	2008-08-08 18:36:13 UTC (rev 33705)
+++ scummvm/branches/gsoc2008-gui/common/xmlparser.h	2008-08-08 18:48:12 UTC (rev 33706)
@@ -423,12 +423,21 @@
 	 * The closedKeyCallback is issued once a key has been finished parsing, to let
 	 * the parser verify that all the required subkeys, etc, were included.
 	 *
+	 * Unlike the keyCallbacks(), there's just a closedKeyCallback() for all keys.
+	 * Use "node->name" to distinguish between each key type.
+	 *
 	 * Returns true if the key was properly closed, false otherwise.
 	 * By default, all keys are properly closed.
 	 */
 	virtual bool closedKeyCallback(ParserNode *node) {
 		return true;
 	}
+	
+	/**
+	 * Called when a node is closed. Manages its cleanup and calls the
+	 * closing callback function if needed.
+	 */
+	bool closeKey();
 
 	/**
 	 * Parses the value of a given key. There's no reason to overload this.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list