[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sat May 22 16:24:01 UTC 2004


CVS commit by okellogg: 

findObjectByIdStr(): Invoke findChildObjectByIdStr on interface/class/enum.
addUMLObject(): Tolerate call with (object->getUMLPackage() != NULL).


  M +29 -4     umldoc.cpp   1.151


--- kdesdk/umbrello/umbrello/umldoc.cpp  #1.150:1.151
@@ -573,8 +573,20 @@ UMLObject* UMLDoc::findObjectByIdStr(QSt
                 if (o->getAuxId() == idStr)
                         return o;
-                if (o->getBaseType() == Uml::ot_Package) {
-                        UMLObject *inner = ((UMLPackage*)o)->findObjectByIdStr(idStr);
+                UMLObject *inner = NULL;
+                switch (o->getBaseType()) {
+                        case Uml::ot_Package:
+                                inner = ((UMLPackage*)o)->findObjectByIdStr(idStr);
                         if (inner)
                                 return inner;
+                                break;
+                        case Uml::ot_Interface:
+                        case Uml::ot_Class:
+                        case Uml::ot_Enum:
+                                inner = ((UMLClassifier*)o)->findChildObjectByIdStr(idStr);
+                                if (inner)
+                                        return inner;
+                                break;
+                        default:
+                                break;
                 }
         }
@@ -636,4 +648,17 @@ void UMLDoc::addUMLObject(UMLObject* obj
                 return;
         }
+        UMLPackage *pkg = object->getUMLPackage();
+        if (pkg != NULL) {
+                // CHECK: If UMLDoc::addUMLObject is invoked on an object
+                // that is inside a package then that is really a misuse.
+                // The following is nothing but a hack to deal with such
+                // misuse:
+                pkg->addObject(object);
+                kdDebug() << "UMLDoc::addUMLObject(" << object->getName()
+                          << "): bad call, adding at containing package instead"
+                          << endl;
+                // end of hack
+                return;
+        }
         //stop it being added twice
         if ( objectList.find(object) == -1)  {






More information about the umbrello-devel mailing list