[Uml-devel] KDE/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Wed Feb 29 06:18:22 UTC 2012


SVN commit 1282856 by okellogg:

UMLDoc::loadFromXMI (tagEq(tag, "Package") ||
                     tagEq(tag, "Class") ||
                     tagEq(tag, "Interface")) :
Do not call loadUMLObjectsFromXMI() because that method again iterates over
the child nodes of the element (not appropriate here because we already
identified the exact tag to load.)
Instead, use Object_Factory::makeObjectFromXMI() for creating and
UMLObject::loadFromXMI() for loading the object.

BUG: 291159


 M  +1 -0      ChangeLog  
 M  +35 -3     umbrello/umldoc.cpp  


--- trunk/KDE/kdesdk/umbrello/ChangeLog #1282855:1282856
@@ -1,6 +1,7 @@
 Version 2.8.2
 
 * New feature: Drawing of state diagrams with more pseudostates possible.
+* Creates many 'new_package_xx' packages on file loading (291159)
 * Color of role text on diagram (e.g. Role B) nearly invisible (291401)
 
 Version 2.8.1
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #1282855:1282856
@@ -1948,9 +1948,36 @@
                        tagEq(tag, "Interface")) {
                 // These tests are only for foreign XMI files that
                 // are missing the <Model> tag (e.g. NSUML)
-                QDomElement parentElem = node.toElement();
-                if( !loadUMLObjectsFromXMI( parentElem ) ) {
-                    uWarning() << "failed load on model objects";
+                QString stID = element.attribute("stereotype", "");
+                UMLObject *pObject = Object_Factory::makeObjectFromXMI(tag, stID);
+                if ( !pObject ) {
+                    uWarning() << "Unknown type of umlobject to create: " << tag;
+                    // We want a best effort, therefore this is handled as a
+                    // soft error.
+                    continue;
+                }
+                UMLObject::ObjectType ot = pObject->baseType();
+                // Set the parent root folder.
+                UMLPackage *pkg = 0;
+                if (ot != UMLObject::ot_Stereotype) {
+                    if (ot == UMLObject::ot_Datatype) {
+                        pkg = m_datatypeRoot;
+                    } else {
+                        Uml::ModelType guess = Model_Utils::guessContainer(pObject);
+                        if (guess != Uml::ModelType::N_MODELTYPES) {
+                            pkg = m_root[guess];
+                        }
+                        else {
+                            uError() << "Guess is Uml::ModelType::N_MODELTYPES - package not set correctly for "
+                                     << pObject->name() << " / base type " << pObject->baseTypeStr();
+                            pkg = m_root[Uml::ModelType::Logical];
+                        }
+                    }
+                }
+                pObject->setUMLPackage(pkg);
+                bool status = pObject->loadFromXMI(element);
+                if (!status) {
+                    delete pObject;
                     return false;
                 }
                 seen_UMLObjects = true;
@@ -2202,8 +2229,13 @@
             continue;
         }
         if (pkg) {
+            UMLObjectList objects = pkg->containedObjects();
+            if (! objects.contains(pObject)) {
+                DEBUG(DBG_SRC) << "CHECK: adding " << pObject->name()
+                               << " to " << pkg->name();
             pkg->addObject(pObject);
         }
+        }
         else if (ot != UMLObject::ot_Stereotype) {
             uError() << "Package is NULL for " << pObject->name();
             return false;




More information about the umbrello-devel mailing list