From 159390bc4646e4c15bcab11433dcc6b0a78cfbd9 Mon Sep 17 00:00:00 2001 From: Adrien Prokopowicz Date: Mon, 9 Jul 2012 22:22:11 +0000 Subject: [PATCH] [GB.XML] * BUG: Getting an attribute that doesn't exist doesn't crashes anymore, it returns a null string instead. * BUG: The string comparison mode argument is now correctly handled by XmlElement.GetAttribute(). git-svn-id: svn://localhost/gambas/trunk@4927 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.xml/src/CElement.cpp | 4 ++-- gb.xml/src/CNode.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gb.xml/src/CElement.cpp b/gb.xml/src/CElement.cpp index 97fa1f2c7..28a82638a 100644 --- a/gb.xml/src/CElement.cpp +++ b/gb.xml/src/CElement.cpp @@ -74,9 +74,9 @@ BEGIN_METHOD(CElement_appendChild, GB_OBJECT newChild) END_METHOD -BEGIN_METHOD(CElement_getAttribute, GB_STRING attrName) +BEGIN_METHOD(CElement_getAttribute, GB_STRING attrName; GB_INTEGER mode) - Attribute *attr = THIS->getAttribute(STRING(attrName), LENGTH(attrName)); +Attribute *attr = THIS->getAttribute(STRING(attrName), LENGTH(attrName), VARG(mode)); if(attr) { GB.ReturnNewString(attr->attrValue, attr->lenAttrValue); diff --git a/gb.xml/src/CNode.cpp b/gb.xml/src/CNode.cpp index 22778ed04..c95206b99 100644 --- a/gb.xml/src/CNode.cpp +++ b/gb.xml/src/CNode.cpp @@ -199,7 +199,14 @@ if(!THIS->isElement()) return; Attribute *attr = THIS->toElement()->getAttribute(STRING(name), LENGTH(name)); -GB.ReturnNewString(attr->attrValue, attr->lenAttrValue); +if(attr) +{ + GB.ReturnNewString(attr->attrValue, attr->lenAttrValue); +} +else +{ + GB.ReturnNull(); +} END_METHOD