[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Thu Jan 15 17:21:02 UTC 2004
CVS commit by okellogg:
Patch reviewed by J. Riddell:
addObject(): Use the object ID as the matching criterion.
load(): Ruggedize. Promote iterator state to `element'.
M +20 -12 package.cpp 1.14
--- kdesdk/umbrello/umbrello/package.cpp #1.13:1.14
@@ -27,5 +27,13 @@ void UMLPackage::init() {
void UMLPackage::addObject(const UMLObject *pObject) {
- if (! m_objects.contains( pObject ))
+ bool alreadyThere = false;
+ int id = pObject->getID();
+ for (UMLObject *o = m_objects.first(); o; o = m_objects.next()) {
+ if (o->getID() == id) {
+ alreadyThere = true;
+ break;
+ }
+ }
+ if (! alreadyThere)
m_objects.append( pObject );
}
@@ -83,7 +91,8 @@ bool UMLPackage::load(QDomElement& eleme
UMLDoc *umldoc = UMLApp::app()->getDocument();
QDomNode node = element.firstChild();
- QDomElement tempElement = node.toElement();
- while (!tempElement.isNull()) {
- QString type = tempElement.tagName();
+ element = node.toElement();
+ while (!element.isNull()) {
+ QString type = element.tagName();
+ QDomElement tempElement = element;
if (type == "UML:Namespace.ownedElement") {
//CHECK: Umbrello currently assumes that nested elements
@@ -94,5 +103,5 @@ bool UMLPackage::load(QDomElement& eleme
return false;
node = node.nextSibling();
- tempElement = node.toElement();
+ element = node.toElement();
continue;
}
@@ -105,14 +114,13 @@ bool UMLPackage::load(QDomElement& eleme
}
pObject->setUMLPackage(this);
- if (! pObject->loadFromXMI(tempElement)) {
- delete pObject;
- return false;
- }
+ if (pObject->loadFromXMI(tempElement)) {
+ addObject(pObject);
if (type == "UML:Generalization")
umldoc->addAssocToConcepts((UMLAssociation *) pObject);
- m_objects.append(pObject);
-
+ } else {
+ delete pObject;
+ }
node = node.nextSibling();
- tempElement = node.toElement();
+ element = node.toElement();
}
return true;
More information about the umbrello-devel
mailing list