[Uml-devel] branches/KDE/4.8/kdesdk/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Wed Feb 29 16:25:59 UTC 2012


SVN commit 1282893 by okellogg:

merge 1282732:1282890 from trunk

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


--- branches/KDE/4.8/kdesdk/umbrello/ChangeLog #1282892:1282893
@@ -13,6 +13,7 @@
 * Crash when opening file (251094) 
 * Crashes even if an association was drawn (271243)
 * Gratuitous warning messages on loading project file (283744)
+* Creates many 'new_package_xx' packages on file loading (291159)
 * Crash on importing templated java source code (293770)
 * New feature: C# code import added.
 
--- branches/KDE/4.8/kdesdk/umbrello/umbrello/umldoc.cpp #1282892:1282893
@@ -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