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

Oliver Kellogg okellogg at users.sourceforge.net
Sun Sep 3 06:58:28 UTC 2006


SVN commit 580285 by okellogg:

UML{Package,Folder,Classifier}::load(): Do the addObject() for contained
 objects in UMLObject::loadFromXMI().  This early adding is needed because
 diagrams are now loaded as part of UMLFolder and objects from nested folders
 must already be present even before the UMLFolder::load() returns so that
 UMLObjects referenced in the diagram can be found.
UMLObject::loadFromXMI(): Do the addObject() here.


 M  +9 -3      classifier.cpp  
 M  +2 -6      folder.cpp  
 M  +2 -13     package.cpp  
 M  +5 -0      umlobject.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/classifier.cpp #580284:580285
@@ -868,6 +868,7 @@
 
 bool UMLClassifier::load(QDomElement& element) {
     UMLClassifierListItem *child = NULL;
+    bool totalSuccess = true;
     for (QDomNode node = element.firstChild(); !node.isNull();
             node = node.nextSibling()) {
         if (node.isComment())
@@ -891,6 +892,7 @@
                             kdError() << "UMLClassifier::load: error from addOperation(op)"
                                       << endl;
                             delete child;
+                            totalSuccess = false;
                         }
                         break;
                     case Uml::ot_Attribute:
@@ -902,23 +904,27 @@
             } else {
                 kdWarning() << "UMLClassifier::load: failed to load " << tag << endl;
                 delete child;
+                totalSuccess = false;
             }
         } else if (!Model_Utils::isCommonXMIAttribute(tag)) {
             UMLDoc *umldoc = UMLApp::app()->getDocument();
             UMLObject *pObject = Object_Factory::makeObjectFromXMI(tag);
-            if( !pObject )
+            if (pObject == NULL) {
+                totalSuccess = false;
                 continue;
+            }
             pObject->setUMLPackage(this);
             if (pObject->loadFromXMI(element)) {
-                addObject(pObject);
                 if (tagEq(tag, "Generalization"))
                     umldoc->addAssocToConcepts((UMLAssociation *) pObject);
             } else {
+                removeObject(pObject);
                 delete pObject;
+                totalSuccess = false;
             }
         }
     }
-    return true;
+    return totalSuccess;
 }
 
 #include "classifier.moc"
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/folder.cpp #580284:580285
@@ -296,9 +296,6 @@
                     totalSuccess = false;
             }
             continue;
-        } else {
-            kdDebug() << "UMLFolder::load(" << m_Name << "): type is "
-                << type << endl;
         }
         // Do not re-create the predefined Datatypes folder in the Logical View,
         // it already exists.
@@ -321,9 +318,8 @@
             continue;
         }
         pObject->setUMLPackage(this);
-        if (pObject->loadFromXMI(tempElement)) {
-            addObject(pObject);
-        } else {
+        if (!pObject->loadFromXMI(tempElement)) {
+            removeObject(pObject);
             delete pObject;
             totalSuccess = false;
         }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/package.cpp #580284:580285
@@ -231,19 +231,8 @@
             continue;
         }
         pObject->setUMLPackage(this);
-        if (pObject->loadFromXMI(tempElement)) {
-            addObject(pObject);
-            /*
-            UMLAssociation *assoc = dynamic_cast<UMLAssociation*>(pObject);
-            if (assoc) {
-                // Adding the UMLAssociation at the participating concepts is done
-                // again later (in UMLAssociation::resolveRef()) if they are not yet
-                // known right here.
-                if (assoc->getObject(Uml::A) && assoc->getObject(Uml::B))
-                    umldoc->addAssocToConcepts(Assoc);
-            }
-             */
-        } else {
+        if (!pObject->loadFromXMI(tempElement)) {
+            removeObject(pObject);
             delete pObject;
         }
     }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #580284:580285
@@ -748,6 +748,11 @@
                     m_pUMLPackage = static_cast<UMLPackage*>( o );
                 }
             }
+        } else if (m_pUMLPackage) {
+            m_pUMLPackage->addObject(this);
+        } else {
+            kdError() << "UMLObject::load(" << m_Name << "): m_pUMLPackage is not set"
+                << endl;
         }
     }
     return load(element);




More information about the umbrello-devel mailing list