[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sat May 22 08:35:10 UTC 2004


CVS commit by okellogg: 

findUMLObject(id): Invoke findChildObject on interfaces/classes/enums.
addUMLObject(): No longer add attributes/operations/enumliterals, they are
 only supposed to be added at their immediate parent classifier.
saveToXMI(): enumliterals/operations/attributes are not supposed to be in
 objectList.


  M +30 -5     umldoc.cpp   1.150


--- kdesdk/umbrello/umbrello/umldoc.cpp  #1.149:1.150
@@ -509,8 +509,20 @@ UMLObject* UMLDoc::findUMLObject(int id)
                 if(obj -> getID() == id)
                         return obj;
-                if (obj->getBaseType() == Uml::ot_Package) {
-                        UMLObject *o = ((UMLPackage*)obj)->findObject(id);
+                UMLObject *o;
+                switch (obj->getBaseType()) {
+                        case Uml::ot_Package:
+                                o = ((UMLPackage*)obj)->findObject(id);
+                                if (o)
+                                        return o;
+                                break;
+                        case Uml::ot_Interface:
+                        case Uml::ot_Class:
+                        case Uml::ot_Enum:
+                                o = ((UMLClassifier*)obj)->findChildObject(id);
                         if (o)
                                 return o;
+                                break;
+                        default:
+                                break;
                 }
         }
@@ -618,4 +630,10 @@ QString	UMLDoc::uniqObjectName(const UML
   */
 void UMLDoc::addUMLObject(UMLObject* object) {
+        UMLObject_Type ot = object->getBaseType();
+        if (ot == ot_Attribute || ot == ot_Operation || ot == ot_EnumLiteral) {
+                kdDebug() << "UMLDoc::addUMLObject(" << object->getName()
+                        << "): not adding type " << ot << endl;
+                return;
+        }
         //stop it being added twice
         if ( objectList.find(object) == -1)  {
@@ -1477,6 +1495,13 @@ void UMLDoc::saveToXMI(QIODevice& file) 
                         continue;
 #endif
-                if (t == ot_Attribute || t == ot_Operation || t == ot_Association)
+                if (t == ot_Association)
                         continue;
+                if (t == ot_EnumLiteral || t == ot_Attribute || t == ot_Operation) {
+                        kdError() << "UMLDoc::saveToXMI(" << o->getName()
+                                  << "): internal error: type " << t
+                                  << "is not supposed to be in objectList"
+                                  << endl;
+                        continue;
+                }
                 o->saveToXMI(doc, objectsElement);
         }






More information about the umbrello-devel mailing list